gleue / TGLStackedViewController

A stacked view layout with gesture-based reordering using a UICollectionView -- inspired by Passbook and Reminders apps.
MIT License
1.21k stars 117 forks source link

Constraints break in ios9 #27

Closed annathomasQB closed 9 years ago

annathomasQB commented 9 years ago

Okay..

So for our project we used TGLStackedViewController and all are happy with the animation and outcome.. except when iOS9 came out. In iOS9, for some reason, not always, the constraints inside a cell breaks and all the subviews come together (not for all cells)

I must admit that I had added some changes to the TGLStackedViewController.m file.. so as to suit the project needs. I can brief the changes that i have made :

-> i change the collectionView frame to position it a bit higher (I have added like a view with buttons above the Collectionview, to act like a fixed header.) - This happens inside an animation, when a user clicks on a cell.. So in effect though the collection view doesn't stand at the top of the screen on launching, when i click on a cell, it goes all the way up. -> i push a ViewController on the ending of the card swipe up animation; That is, when a user clicks a cell, and it gets animated to the top and the rest of the cards go down, i push a ViewController that has the exact look and feel of the Collectionview cell. -> from this new viewController, on a button action, a pop this view and the raised card slides back into the stack..

It looks awesome in ios8!!

But in iOS9, when we play with tha animations, at some point, for some cells, the constraints break..

I cannot blame TGLStack because this issue doesn't happen when i don't push the viewcontroller.. but since it doesnt happen to OS prior to iOS9.. I am desperately searching for a solution..

I am writing to you so as to get a sense of direction.. :) Some inputs from you can maybe help me sort out things.. Please help!!!

gleue commented 9 years ago

You most probably already checked all your constraints for warnings in IB and for console message at run-time etc.?

The extra VC is pushed (on a navigation stack) or presented modally? In a UINavigationController or not? Any console output at run-time when presenting/dismissing it?

annathomasQB commented 9 years ago

Yes I did check..

There are no warning thrown when the constraints break, and there are no warnings in IB too..

The extra VC is pushed on the navigation stack.. This VC is taken from another storyboard..

In a UINavigationController or not? -> The TGLStack inherited VC is inside a UINavigationController in storyboard, but the pushed VC is not in a NavigationController in storyboard..

I am pushing the VC from TGLStackVC's method setExposedItemIndexPath:

in this method, there's a line of code like this : [self.collectionView setCollectionViewLayout:exposedLayout animated:YES completion:^(BOOL finished) { }

its inside this completion block that i call the next VC like this :

// next VC's weakSelf reference created and then the following code is called:

[weakSelf.navigationController pushViewController:weakSelf.nextVC animated:NO];

I tried presenting the VC modally too but the issue was still there..

I was getting constraint issues in the log for the presented VC, but not the the VC that's inheriting TGLStackedViewController

annathomasQB commented 9 years ago

I saw that this issue is there even when the cards are not exposed..

I tried a simple pushVC on button action.. from a view on the VC. on pop form that VC, we sometimes get that issue..

gleue commented 9 years ago

I tried pushing/presenting a UIViewController in setCollectionViewLayout:animated:completion completion block as you did, and it doesn't seem to work very well in general, when TGLStackedVC is embedded inside a UINavigationController.

When run in instruments it takes several seconds for UIKIt to set up the layout transition animations when in a UINavigationController, but not when stand-alone.

Not sure if that has something to do with it, but there seems to be an issue in conjunction w/ the navigation controller.

gleue commented 9 years ago

Did you find this one: http://stackoverflow.com/questions/27031145/why-does-modally-presenting-a-view-controller-break-auto-layout-in-my-table-view

gleue commented 9 years ago

And for the VC presentation from cell: http://zappdesigntemplates.com/uiviewcontroller-transition-from-uicollectionviewcell/

annathomasQB commented 9 years ago

Hi @gleue ,

Thanks for that input!!

I'm trying both options..

First will try with the VC presentation from cell..

If that doesn't work, will try removing the TGLStackVC inherited VC from Navigation controller.

Will post you with the updates...

Thanks again for that input!! cos now it has given me a sense of direction :)

annathomasQB commented 9 years ago

Hi @gleue,

I tried removing the inherited VC from Navigation controller, but the constraints issues are still there :(

Going to try out the transitioning delegate method.. hope that it works!!

annathomasQB commented 9 years ago

@gleue ...

Am feeeling really really dumb right now..

it was actually my fault.. I had set my constraints using the size class width-Compact and height-Regular (iphone portrait)...

when i fixed the constraints using size class Any-Any.. everything started working fine..

I was wrong..

And i feel so so dumb..

TGLStackedViewController is SUPER POWERFUL!! And i love it even more...

Thanks a lot for your patience.. :)

I hope you're not mad about me wasting your time..

gleue commented 9 years ago

Don't worry, that's the kind of mistakes we all make. And that we learn most from :)

annathomasQB commented 9 years ago

True that!!!

Thanks again :)