Question

I created a view controller and set its frame.y to 80, later I need to show another modal view controller when the modal VC dismisses, the viewWillAppear of the first view controller is called, then its frame.y is set back to 0.

Can I prevent this behaviour? I know I can in its viewWillAppear reset the frame.y to 80. But is there any smarter way?

Was it helpful?

Solution

This may be happening because of AutoLayout... Try NSLogging to see if the variables changes when ViewDidAppear is being called or after it is done being called... What about ViewDidLoad? In your .h file you could create and integer and in the ViewDidLoad set it equal to frame.y, then in ViewDidAppear after is has been reset to zero just change it back to that integer... that way you don't have to worry about the hassle of changing that piece of code every time you adjust the size in the xib file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top