ios - 字体大小更改部分页脚 TableView

标签 ios swift uitableview ios-autolayout

我目前正在使用 Swift 构建 iOS 应用程序,但遇到了一些问题。我的设置 View 是一个 TableView Controller 。这是一组的。我的表格 View 是动态的,字体也是动态的。

我想通过设置应用程序与字体大小的更改进行交互。

如果我的应用程序已经在运行,字体大小会发生变化,但布局会被破坏。 (字体由最小变为最大)

图片:Layout bug

如果我使用新的字体设置重新启动应用程序,就不会出现问题...

这是一个 XCODE project example ,您会看到该错误。

您能帮我找到解决方案吗?谢谢。

最佳答案

UIContentSizeCategory DidChangeNotification 就是您要寻找的内容。

根据文档:

Posted when the user changes the preferred content size setting.

This notification is sent when the value in the preferredContentSizeCategory property changes. The userInfo dictionary of the notification contains the UIContentSizeCategoryNewValueKey key, which reflects the new setting.

回调实现示例:

 func handleContentSizeCategoryDidChangeNotification(notification: NSNotification) {
         self.questionLabel.font = UIFont.preferredFontForTextStyle(UIFontTextStyleBody)
    }

关于ios - 字体大小更改部分页脚 TableView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36365902/

相关文章:

ios - 向 UITableView 添加了错误的对象

ios - UITextView:在截断的文本中查找省略号的位置

ios - 错误体系结构armv7的 undefined symbol : “_RELEASE_SAFELY” , referenced from:

ios - 如何切换到 "More" View 中的标签栏项目?

ios - 在 GameScene 和 ViewController 之间移动 Swift

json - Swift 4 JSON解码

swift - 如何在 tableview 列表中异步加载视频 url 缩略图

ios - 有没有办法强制异步 NSURLConnection 在后台调用 connectionDidFinishLoading?

ios - 如何获取注释放置 iOS 的时间

ios - 具有两个标识符的表格 View 单元格。对于 TableView 中的奇数一个单元格和甚至另一个单元格