使用警报与文本字段使用警报时的错误/警告
使用文本字段创建警报时,我会收到以下警告/错误。当我删除Textfield时,消息会消失。
不支持由UicollectionView管理的UicollectionViewCell的翻译autoresizingmaskIntocontaints属性,不支持由UicollectionView管理,并且会导致不正确的自我规模。查看:< _uialertControllerTextFieldViewCollectionCell:0x1529254E0;帧=(0 0; 270 24); GesturerEcognizers =< nSarray:0x600000d56be0>;; layer =< calayer:0x6000003b5a80>
我没有收集视图,而且我也没有更改或设置为false translatesautoresautiesizingmaskIntocontaints属性,这就是为什么我不了解消息的原因。
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(createAlert))
}
@objc private func createAlert() {
let alert = UIAlertController(title: "Alert Title", message: nil, preferredStyle: .alert)
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
let okAction = UIAlertAction(title: "OK", style: .default) { _ in
print("Action") }
alert.addAction(okAction)
alert.addAction(cancelAction)
alert.addTextField { textField in
}
present(alert, animated: true)
}
我该如何解决?不幸的是,我在研究中没有找到解决方案。警告不仅在模拟器上,而且在物理设备(iPhone X)上发出。
I get the following warning/error when I create an alert with text field. When I remove the textfield, the message disappears.
Changing the translatesAutoresizingMaskIntoConstraints property of a UICollectionViewCell that is managed by a UICollectionView is not supported, and will result in incorrect self-sizing. View: <_UIAlertControllerTextFieldViewCollectionCell: 0x1529254e0; frame = (0 0; 270 24); gestureRecognizers = <NSArray: 0x600000d56be0>; layer = <CALayer: 0x6000003b5a80>>
I don't have a collection view and also I haven't changed or set to false the translatesAutoresizingMaskIntoConstraints property of a cell, that's why I don't understand the message.
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(createAlert))
}
@objc private func createAlert() {
let alert = UIAlertController(title: "Alert Title", message: nil, preferredStyle: .alert)
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
let okAction = UIAlertAction(title: "OK", style: .default) { _ in
print("Action") }
alert.addAction(okAction)
alert.addAction(cancelAction)
alert.addTextField { textField in
}
present(alert, animated: true)
}
How can I solve this? Unfortunately, I have not found a solution in my research. The warning occurs not only on the simulator, but also on physical devices (iPhone X).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论