【发布时间】:2015-10-09 14:56:28
【问题描述】:
我在 iOS9 上遇到了 UIAlertController 的问题......它在 ios8 上很好,但现在它给了我下一个结果:
使用 Alert 样式可以正常工作,但使用 ActionSheet 样式时效果很奇怪,并且会出现以下错误:
无法同时满足约束。可能至少有一个 以下列表中的约束是您不想要的。尝试 这个:(1)查看每个约束并尝试找出你 不要期待; (2) 找到添加了不需要的约束的代码或 约束并修复它。 (注:如果你看到 NSAutoresizingMaskLayoutConstraints 你不明白的,参考 到 UIView 属性的文档 translatesAutoresizingMaskIntoConstraints) ( "", "=10)]>", "", "")
将尝试通过打破约束来恢复
在 UIViewAlertForUnsatisfiableConstraints 创建一个符号断点 在调试器中捕获它。中的方法 UIView 上的 UIConstraintBasedLayoutDebugging 类别列于 也可能有帮助。 2015-10-09 16:41:29.613 OnskeskyenShareExtension[53993:14714610] 无法同时 满足约束。可能至少有一个约束条件 以下列表是您不想要的。试试这个:(1)看每个 约束并尝试找出您不期望的; (2) 找到 添加不需要的约束或约束并修复它的代码。 (注意:如果您看到 NSAutoresizingMaskLayoutConstraints 不明白,参考UIView属性的文档 translatesAutoresizingMaskIntoConstraints) ( "", "=12)-[UIView:0x7f8f69cde5e0](名称: '|':_UIAlertControllerActionView:0x7f8f69cddec0)>", "", "", "")
将尝试通过打破约束来恢复
在 UIViewAlertForUnsatisfiableConstraints 创建一个符号断点 在调试器中捕获它。中的方法 UIView 上的 UIConstraintBasedLayoutDebugging 类别列于 也可能有帮助。
我的代码是:
func createActionPicker(){
self.alertController = UIAlertController(title: "", message: "", preferredStyle: UIAlertControllerStyle.ActionSheet);
self.alertController.modalInPopover = false;
for i in 0...self.listData.count-1{
let action = UIAlertAction(title: self.listData[i], style: .Default, handler: {(alertAction:UIAlertAction) in
self.dropDownListText.text = alertAction.title;
for j in 0...self.alertController.actions.count-1{
if(alertAction.isEqual(self.alertController.actions[j])){
self.selectedIndex = j;
break;
}
}
});
self.alertController.addAction(action);
}
self.alertController.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil));
let alertView = UIView(frame: self.frame);
self.addSubview(alertView)
}
public func dropDown(sender:UIView)
{
if(self.listData.count == 0) {return}
if(UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad)
{
self.popover.presentPopoverFromRect(self.dropDownButton.frame, inView: self, permittedArrowDirections: UIPopoverArrowDirection.Right, animated: true);
}
if(UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Phone)
{
dispatch_async(dispatch_get_main_queue(), {
self.viewController.presentViewController(self.alertController, animated: true, completion: nil);
});
}
}
谁能帮我解决这个烦人的问题?!
【问题讨论】:
-
您找到解决方案了吗?我从 2 天开始就一直在苦苦挣扎。
标签: iphone swift uialertview ios9