sen*_*lim 8 iphone ios swift uialertcontroller
我是iOS开发的新手.我试图显示UIAlertController单击按钮的时间(故事板为空,故事板中只有1个按钮),使用下面的代码
@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)
}
Run Code Online (Sandbox Code Playgroud)
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>,它附加到; layer =; contentOffset:{0,0}; contentSize:{0,0}>集合视图布局:<_ UIAlertControllerCollectionViewFlowLayout:0x7fd6b8582d90>.
如果我删除文本字段UIAlertController或删除2个按钮(保持显示文本字段),它不会显示警告.任何解释为什么会这样?如何修复警告?
J.W*_*ams 18
尝试:
yourAlertController.view.setNeedsLayout()
Run Code Online (Sandbox Code Playgroud)
就在它出现之前 presentViewController:
编辑:我已将此错误提交给Apple
| 归档时间: |
|
| 查看次数: |
2067 次 |
| 最近记录: |