【发布时间】:2019-09-08 10:27:24
【问题描述】:
我想在我的应用程序中实现动态类型,以便应用程序可以适应用户的字体偏好。我有一个带有 3 个静态单元格的表格视图。第一个和第二个有UITextField,它们工作正常,没有任何问题。第三个是UITextView 的单元格不能缩放。动态类型设置为开启,字体为正文。
这是我在UITableViewController 中的代码。
override func viewDidLoad() {
super.viewDidLoad()
tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 100
setupTextFieldsAndTextView()
}
func setupTextFieldsAndTextView() {
emailTF.keyboardType = UIKeyboardType.asciiCapable
titleTF.keyboardType = UIKeyboardType.asciiCapable
messageTextView.keyboardType = UIKeyboardType.asciiCapable
emailTF.returnKeyType = .next
titleTF.returnKeyType = .next
messageTextView.returnKeyType = .default
emailTF.delegate = self
titleTF.delegate = self
messageTextView.delegate = self
}
和UITableView 代表
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
我希望拥有与 iOS 日历应用程序相同的设计。基于所选字体类型的单元格比例,但UITextView 仍然是可滚动的,并且里面的文本也由用户选择。屏幕中的UITextView 是一个带有文本占位符“Notes”的单元格。
【问题讨论】:
-
@ShadeToD :当您声称带有 UITextView 的单元格不随动态类型缩放时,您是在谈论高度还是字体大小?
-
@XLE_22 我的意思是单元格的高度和该单元格内文本的字体。从 iOS 日历应用中查看 2 张照片。它缩放单元格高度以及单元格内的文本。 (带有占位符“备注”的单元格)
-
你可以试试你的textview单元听
UIContentSizeCategory.didChangeNotification然后刷新你的textview?
标签: ios swift accessibility dynamic-type-feature