UIAlertController iPhone 6/6s plus UICollectionViewFlowLayout error

alert window created with UIAlertController, is producing an error when runs on 6/6s plus simulator:

2015-09-16 22:09:26.187 To Do[7428:1127563] the behavior of the UICollectionViewFlowLayout is not defined because:
2015-09-16 22:09:26.188 To Do[7428:1127563] 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-09-16 22:09:26.189 To Do[7428:1127563] The relevant UICollectionViewFlowLayout instance is <_UIAlertControllerCollectionViewFlowLayout: 0x7fe8ba5908f0>, and it is attached to <UICollectionView: 0x7fe8bb87fe00; frame = (0 96.6667; 270 44); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x7fe8ba5915a0>; layer = <CALayer: 0x7fe8ba591120>; contentOffset: {0, 0}; contentSize: {0, 0}> collection view layout: <_UIAlertControllerCollectionViewFlowLayout: 0x7fe8ba5908f0>.
2015-09-16 22:09:26.189 To Do[7428:1127563] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.


function I am using to create alert window:

func alertPopup(){
        let alert = UIAlertController(title: "Add New Item", message: nil, preferredStyle: UIAlertControllerStyle.Alert)
        let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel){
            UIAlertAction in alert.dismissViewControllerAnimated(true, completion: nil)
        }
        let saveAction = UIAlertAction(title: "Save", style: UIAlertActionStyle.Default){
            UIAlertAction in self.saveNewItem()
        }
        alert.addTextFieldWithConfigurationHandler({(textField: UITextField!) in
            textField.placeholder = "new note"
            self.tField = textField
        })
        alert.addAction(cancelAction)
        alert.addAction(saveAction)
       
        self.presentViewController(alert, animated: true, completion: nil)     
       
    }


Not really sure how to fix that error?

I am using stable xcode 7. Had same error with 7beta and 7.1beta version of xcode.

Replies

same problem here 😟

same problem

+1

Just converting my app to Swift 2 using Xcode 7 and I am getting this same error. It wasn't there before.

did report as a bug.

some error after start using Xcode 7

I had the same issue.


In my case, I had a collection view and when you tapped on one of the cells, a popover with a textfield opened, to edit the item. After that popover disappeared, the self.collectionView?.contentInset.bottom was set to 55 (from 0).


To fix my issue, after the popover view disappears, I’m manually setting contentInset to UIEdgeInsetsZero.


I hope it helps.

Me too post here.


XCode 7.1 Beta 3

try

yourAlertController.view.setNeedsLayout()


just before presenting it

This seems to "fix" the issue in portrait, but not landscape. I'm not getting this on 6s, only plus (simulator).

I had the same problem: worked fine on iPhone 6 Plus portrait, failed in landscape. I made one small change: from

     message: nil,

to:

     message: "this is a nice long line of crapthis is a nice long line of crapthis is a nice long line of crap",

..which was long enough to wrap, adding two newlines. And my problem was solved.


I then found that

     message: "\n\n"

worked just as well, but a message of a single newline failed. If I set title: nil, I needed more newlines in message. It appears to be related to the total height of the alert, title and message combined.


Note: other alerts without a text field didn't show the same problem. And in my case, setNeedsLayout() didn't make any difference.


Mind you, adding that tall message for fixing the alert on iPhone 6 Plus makes it too tall to display on iPhone 5 in landscape (remember, there's a pop-up keyboard onscreen, too). When this tall alert tries to display, it generates the same flood of UICollectionViewFlowLayout errors. I wound up making the "tall" message conditional on the screen's height & width exceeding 400 pixels, so I get a short, message-less alert on iPhone 5 & 6 and a tall one with a wordy message on iPhone 6 Plus or iPad, and I don't get any more errors (at least not on my test devices: iPhone 5, 6 Plus, and iPad Air).

This doesn't help me. Mine is Version 7.3.1. My device iPhone 6 plus.

The line break doesn't help. Mine is Version 7.3.1. My device iPhone 6 plus.

Where can I check the bug status? To see if it's fixed or has a workaroud.

+1 Same problem

xCode Version 7.3.1. device iPhone 6 plus.