我是iOS开发的新手。我试图在UIAlertController
单击按钮时显示一个(故事板为空,故事板中只有一个按钮),使用下面的代码
@IBAction func showAlert(sender: UIBarButtonItem) {
let alert = UIAlertController(
title: "Create new",
message: "Hi",
preferredStyle: UIAlertControllerStyle.Alert
)
let createAction = UIAlertAction(title: "Ok", style: .Default, handler: nil)
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)
alert.addAction(createAction)
alert.addAction(cancelAction)
alert.addTextFieldWithConfigurationHandler {
$0.placeholder = "Test placeholder"
}
presentViewController(alert, animated: true, completion: nil)
}
iPhone 5、5S,6、6S不显示警告,但是iPhone 6plus和6S Plus显示警告
2015-10-20 22:38:54.007 TestApp [3128:48601]未定义UICollectionViewFlowLayout的行为,因为:2015-10-20 22:38:54.008 TestApp [3128:48601]项目高度必须小于UICollectionView的高度减去该部分可插入顶部和底部值,减去内容可插入顶部和底部值。2015-10-20 22:38:54.008 TestApp [3128:48601]相关的UICollectionViewFlowLayout实例为<_UIAlertControllerCollectionViewFlowLayout:0x7fd6b8582d90>,并将其附加到; 层=; contentOffset:{0,0}; contentSize:{0,0}>集合视图布局:<_UIAlertControllerCollectionViewFlowLayout:0x7fd6b8582d90>。
如果我删除了上的文本字段UIAlertController
或删除了2个按钮(保持显示的文本字段),则不会显示警告。为什么会发生这种情况的任何解释?如何解决警告?
尝试:
yourAlertController.view.setNeedsLayout()
在介绍它之前 presentViewController:
编辑:我已将此错误提交给Apple
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句