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

FSCalendar has problem with rotating to landscape #182

Closed
marianvinicay opened this issue Jan 10, 2016 · 9 comments
Closed

FSCalendar has problem with rotating to landscape #182

marianvinicay opened this issue Jan 10, 2016 · 9 comments

Comments

@marianvinicay
Copy link

FSCalendar works with no problem when the device is in portrait, but as soon as the device rotates to landscape, the app prints out this.

2016-01-10 18:05:43.818 the behavior of the UICollectionViewFlowLayout is not defined because:
2016-01-10 18:05:43.818 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.
2016-01-10 18:05:43.819 The relevant UICollectionViewFlowLayout instance is <UICollectionViewFlowLayout: 0x7f9b5c115880>, and it is attached to <FSCalendarCollectionView: 0x7f9b5d808200; baseClass = UICollectionView; frame = (0 3.82667; 333.5 34.44); clipsToBounds = YES; userInteractionEnabled = NO; gestureRecognizers = <NSArray: 0x7f9b5c10bc80>; layer = <CALayer: 0x7f9b5c10c4b0>; contentOffset: {96, 0}; contentSize: {2681, 39.960000000000001}> collection view layout: <UICollectionViewFlowLayout: 0x7f9b5c115880>.
2016-01-10 18:05:43.819 Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.

Maybe the problem is caused by the changing of constraints during rotation because I want to use different layout in the landscape as is in the portrait. Whole layout "thing"(AutoLayout,Size Classes) is done in storyboard, nothing in code.

The portrait layout:
snimka obrazovky 2016-01-10 o 16 40 44

The landscape layout:
snimka obrazovky 2016-01-10 o 18 10 13

@WenchaoD
Copy link
Owner

WenchaoD commented Feb 3, 2016

Try latest version?

@carlos-maldonado-em
Copy link

I'm having this issue and using Pods brought version: FSCalendar (2.1.1), is this the latest one?
This occurs if I set scope to be Week at startup it doesn't show if scope is Month.

Also noticed that either scope, at startup, my app doesn't have the necessary data to load the calendar, so after I received my data, I call myFSCalendar.setNeedsLayout but doesn't refresh. Is there a way to refresh the view once it's already loaded?

@WenchaoD
Copy link
Owner

WenchaoD commented May 5, 2016

@carlos-maldonado-em use calendar.reloadData to refresh

@carlos-maldonado-em
Copy link

great!... that did it for the refresh of the UI, thank you. What about the other issue?: "the behavior of the UICollectionViewFlowLayout is not defined because...". It slows down the app because there are 4,369 warnings of this type.

@WenchaoD
Copy link
Owner

WenchaoD commented May 5, 2016

Hi @carlos-maldonado-em
I need an example project that reproduce this, can you make one and share it with dropbox?

@carlos-maldonado-em
Copy link

carlos-maldonado-em commented May 6, 2016

Hi WenchaoD, I tried to create a project for you but in that project the failure doesn't show at startup. It only shows when you rotate to landscape.

I tried these workarounds (independently of each other):
-If I set the scope to Month and change it in viewDidAppear to Week, the error doesn't show.
-If I set the height constraint at runtime in the boundingRectWillChange, the error doesn't show BUT fontsize and in general, collection cells become bigger.

I just dropped it to the dropbox and shared it with you using your email you have in github.

thanks!

@WenchaoD
Copy link
Owner

WenchaoD commented May 7, 2016

Remove the constraints in the picture below, and take care of the warning in the console.
image

Result is:

image

and:

image

@carlos-maldonado-em
Copy link

I did try your suggestion and it worked but then I realized it has something to do with the size (height) of the FSCalendar object. I updated the project in the dropbox so you can try it. It fails when the size is between in the range [240...267]. I didn't test nor check further on why this could be the case or if there are any other range where it fails, but for sure it fails on that range.

Changing the height size of the constraint, so the FSCalendar object updates, then running the project will produce the failure if the size is within that range, otherwise, it'll work with no failure.

Curious thing is that in another project I have, it fails with all values.

@carlos-maldonado-em
Copy link

Hi Wenchao,

Finally I found a workaround, at least the problem hasn't shown any longer. I'm calling the fsCalendar.setScope(scope, animated: true) just before doing the fsCalendar.reloadData(), where scope value is .Week. The only thing is that this solution must be implemented in the viewDidAppear method, or once the view it's already showing to the user and makes the UI to 'jump' a bit from .Month to .Week but that is acceptable, as the problem with UICollectionViewFlowLayout was that the UI was consuming a lot of time while being laid out.

thanks for your support!

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
@WenchaoD @marianvinicay @carlos-maldonado-em and others