Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"negative or zero item sizes are not supported in the flow layout" in simulator #146

Closed
tomoyuki28jp opened this issue Sep 11, 2015 · 13 comments

Comments

@tomoyuki28jp
Copy link

My iPhone simulator (iPhone6 / iOS8.4) has 10 images in the Camera Roll album. But when I try to select album in the simulator, I get this error: "negative or zero item sizes are not supported in the flow layout". And I cannot select any image.

@tomoyuki28jp
Copy link
Author

And some autolayout warnings:

2015-09-12 07:28:02.193 App[17678:423335] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSLayoutConstraint:0x7f8184288000 CTAssetsPickerNoAssetsView:0x7f818415ee50.leading == UICollectionViewControllerWrapperView:0x7f8185b668c0.leadingMargin>",
    "<NSLayoutConstraint:0x7f818427c040 CTAssetsPickerNoAssetsView:0x7f818415ee50.trailing == UICollectionViewControllerWrapperView:0x7f8185b668c0.trailingMargin>",
    "<NSLayoutConstraint:0x7f818428faf0 'UIView-Encapsulated-Layout-Width' H:[UICollectionViewControllerWrapperView:0x7f8185b668c0(0.5)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7f818427c040 CTAssetsPickerNoAssetsView:0x7f818415ee50.trailing == UICollectionViewControllerWrapperView:0x7f8185b668c0.trailingMargin>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2015-09-12 07:28:02.194 App[17678:423335] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSLayoutConstraint:0x7f8184288000 CTAssetsPickerNoAssetsView:0x7f818415ee50.leading == UICollectionViewControllerWrapperView:0x7f8185b668c0.leadingMargin>",
    "<NSLayoutConstraint:0x7f818428faf0 'UIView-Encapsulated-Layout-Width' H:[UICollectionViewControllerWrapperView:0x7f8185b668c0(0.5)]>",
    "<NSLayoutConstraint:0x7f81842cc510 CTAssetsPickerNoAssetsView:0x7f818415ee50.centerX == UICollectionViewControllerWrapperView:0x7f8185b668c0.centerX>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7f81842cc510 CTAssetsPickerNoAssetsView:0x7f818415ee50.centerX == UICollectionViewControllerWrapperView:0x7f8185b668c0.centerX>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2015-09-12 07:28:02.194 App[17678:423335] negative or zero item sizes are not supported in the flow layout

@1and2papa
Copy link
Owner

Hi @tomoyuki28jp, may I know the Xcode version, simulator OS version and the simulator device model?

@tomoyuki28jp
Copy link
Author

Thanks for your reply, @chiunam

Xcode

Version 6.4 (6E35b)

iOS Simulator

Version 8.4 (SimulatorApp-565.9 CoreSimulator-117.15)
iPhone 6 / iOS 8.4

@tomoyuki28jp
Copy link
Author

When I re-try to select images on the same simulator again, it works fine now somehow. Wired. I close this issue for now. Sorry to bother you and thanks for your great work!

@joachimboggild
Copy link

I have just experienced the same issue. Runnning XCode 7, iOS9, this module bridged into a swift project, using Iphone 6S plus simulator. Exactly the same error message. No autolayout warnings, though.

Next time I tried running the simulator, the problem did not appear.

So I would say that the issue is transient, but not fixed :-(

... maybe the module writes some settings that it misses the first time around?

... nice work with this module, though!

@1and2papa
Copy link
Owner

@joachimboggild Thanks for reporting. Let's keep this issue in view.

@1and2papa 1and2papa reopened this Oct 6, 2015
@barba77
Copy link

barba77 commented Oct 12, 2015

Hi! That issue happens when the app does not have permission to access the photo library yet.

You can reproduce it on simulator resetting its contents ("reset content and settings ...") and running your app again.

@tomoyuki28jp
Copy link
Author

Yeah, it seems like what @barba77 said is correct.

@1and2papa
Copy link
Owner

It's strange. I cannot reproduce issue on Xcode 7.0 and 7.1 beta.

BTW, if the app does not have permission, it should show lockpad screen.

simulator screen shot 16 oct 2015 4 17 10 pm

@tomoyuki28jp
Copy link
Author

@chiunam

How to reproduce this error

  1. Start Simulator App
  2. Reset Content and Setting
  3. Finish Simulator App
  4. Run app on Simulator
  5. Present Asset Picker
  6. "App" Would Like to Access Your Photos and select OK
  7. negative or zero item sizes are not supported in the flow layout error occurs

@1and2papa
Copy link
Owner

Still no luck for me. Have it googled and found some related questions in SO. It should be raised from the collection view layout object. Probably it cannot calculate the item size from content size of the view controller in certain scenarios.

I recalled that the UICollectionViewController occasionally return improper bounds size when I developed this picker. That might be due to different sequence of initiating views and view controllers.

I'll try to create an experimental branch and add a checking of negative or zero item sizes. If it occurs, it will return a predefined item sizes. It should eliminate the error but the grid size will be different.

kirillivonin pushed a commit to kirillivonin/CTAssetsPickerController that referenced this issue Feb 2, 2016
"negative or zero item sizes are not supported in the flow layout" in simulator"
1and2papa added a commit that referenced this issue Feb 24, 2016
fixed issue #146 and controller containment
@1and2papa
Copy link
Owner

@tomoyuki28jp @joachimboggild @barba77, I have merged the fix from @kirillivonin in v3.3.1. Please report if this issue reappears again.

@tomoyuki28jp
Copy link
Author

@chiunam Thank you for your work! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants