I’m using this.
I’ve put this in where the images are added:
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
I’ve put these overrides in SlideShowViewController:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return YES;
}
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)InterfaceOrientation duration:(NSTimeInterval)duration {
}
The first is called, but not the second.
I’m not using a nib; it uses a custom init which returns a self.view with the 3 images on it.
Am I missing something? What would be the best way to modify this script to get the landscape photos stretch to full width when the iPhone is rotated by the user?
Edit: Just tried adding willAnimate… to the Root View Controller of my NavigationController, but it’s not invoked. Perhaps the NavigationController is the problem? In that case, where do I put the willAnimate…? Alternatively, how do I receive and pass on messages sent to it towards the visible viewController?
Edit 2: Cause of the error in topic was that the TabBarController was missing a connection in IB (which I was sure was there). So now my problem is the same as for a few other similar questions – willAnimate… is called in root VC but not in the pushed VCs. The code I’ve used fades in the gallery VC rather than slide it in, ie. it’s not pushed but currently added as a subview to the window – to fill the entire display.
Suggestions for how to message that subview’s controller to set the frames would be appreciated, or alternate solutions!
This is not an answer to why your “willAnimateRotation..”-method doesn’t trigger but instead an alternative to how the image gallery can adapt to rotations itself.
In initWithImages add:
Add this method to receive the notification. In didRotate you can handle the resizing an repositioning of the images.
Don’t forget to unregister the notification in dealloc:
May I also suggest that you use a UIScrollView instead of handling scrolling and gestures yourself?