使用警报与文本字段使用警报时的错误/警告

发布于 2025-02-13 15:24:46 字数 1313 浏览 1 评论 0原文

使用文本字段创建警报时,我会收到以下警告/错误。当我删除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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文