相关疑难解决方法(0)

iOS 8.3 UIAlertController在尝试添加文本字段时崩溃

我有一个iPad应用程序.我正在创建一个UIAlertController并添加一个文本字段.它崩溃了.它只在我添加文本字段时崩溃.

let alert = UIAlertController(title: "Enter Name", message:nil, preferredStyle: UIAlertControllerStyle.Alert);         
alert.addTextFieldWithConfigurationHandler { (textfield:UITextField!) -> Void in
                textfield.placeholder = "Sexy time";

            }
 alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: {(action:UIAlertAction!) -> Void in
      //Some action here   
 }));

 self.presentViewController(alert, animated: true, completion: nil);
Run Code Online (Sandbox Code Playgroud)

我得到一个有趣的崩溃告诉我,约束搞砸了.此代码在<8.3中正常工作,没有任何警告.即使在一个没有任何内容的干净项目中,但是这个代码崩溃了 - 该项目需要成为iPad上的splitview项目.

这是完整的堆栈跟踪加上奇怪的约束警告,只有在尝试将文本字段添加到alertController后才会出现.

2015-04-10 15:25:07.155 Observation[18235:281813] The view hierarchy is not prepared for the constraint: <NSLayoutConstraint:0x7fb66cf9dfc0 UITableView:0x7fb66b855000.left == UIView:0x7fb66fae68e0.left>
    When added to a view, the constraint's items must be descendants of that view (or the view itself). This will crash …
Run Code Online (Sandbox Code Playgroud)

crash ios uialertcontroller ios8.3

16
推荐指数
2
解决办法
7224
查看次数

标签 统计

crash ×1

ios ×1

ios8.3 ×1

uialertcontroller ×1