I'm a newbie in iOS development. I was trying to display a UIAlertController
when a button is clicked (The storyboard is empty, there's only 1 button in the storyboard), using below code
@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 do not show warnings, however iphone 6plus and 6s plus shows warning
2015-10-20 22:38:54.007 TestApp[3128:48601] the behavior of the UICollectionViewFlowLayout is not defined because: 2015-10-20 22:38:54.008 TestApp[3128:48601] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values. 2015-10-20 22:38:54.008 TestApp[3128:48601] The relevant UICollectionViewFlowLayout instance is <_UIAlertControllerCollectionViewFlowLayout: 0x7fd6b8582d90>, and it is attached to ; layer = ; contentOffset: {0, 0}; contentSize: {0, 0}> collection view layout: <_UIAlertControllerCollectionViewFlowLayout: 0x7fd6b8582d90>.
If I remove the text field on UIAlertController
or I remove the 2 buttons (keep the text field displayed), it does not show warnings. Any explanation why this happens? How to fix the warning?
try:
yourAlertController.view.setNeedsLayout()
just before presenting it with presentViewController:
edit: I have submitted this bug to Apple
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With