Hello,
I've been attempting to replace one UIView with another when rotating the iphone. I can replace the one view for another via the following code, but the views "walk" off the containing view and get resized smaller:
The two views I'm switching are the current view in the navigation controller and a card view. The card view is what is displayed when the in portrait mode. I put a containing view for both the navView and cardView to be placed in the hopes that I could have more control. All views have their own controllers and everything was wired up in IB (animation code has been removed just get it to work):
The first time I rotate to the card view it looks okay. Moved down a bit but okay. When I then rotate back to the navView it gets allocated about 1/4 of the screen vertically. The next rotation is worse for both and finally they are no longer visible.
The rotation is triggered in the baseViewController (the container) via this:
I tried it in the willRotateToInterfaceOrientation, willAnimateSecondHalfOfRotationFromInterfaceOrientation and didRotateFromInterfaceOrientation methods also with the same basic results.
My thoughts had been to set the new shown view's bounds to bounds of the container view, but the container view's bounds are always null!
I've seen this done before in videos so I know it works, but any help would be greatly appreciated.
Thanks,
Charlie
I've been attempting to replace one UIView with another when rotating the iphone. I can replace the one view for another via the following code, but the views "walk" off the containing view and get resized smaller:
The two views I'm switching are the current view in the navigation controller and a card view. The card view is what is displayed when the in portrait mode. I put a containing view for both the navView and cardView to be placed in the hopes that I could have more control. All views have their own controllers and everything was wired up in IB (animation code has been removed just get it to work):
Code:
- (void)toggleCardAndDeckView {
UIView *navView = navigationController.view;
UIView *cardView = cardViewController.view;
UIView *baseView = baseViewController.view;
if ([navView superview] == nil) {
[cardView removeFromSuperview];
[baseView addSubview:navView];
}
else {
[navView removeFromSuperview];
[baseView addSubview:cardView];
}
}
The rotation is triggered in the baseViewController (the container) via this:
Code:
- (void)willRotateToInterfaceOrientation: (UIInterfaceOrientation)toInterfaceOrientation
duration: (NSTimeInterval)duration {
CardsAppDelegate *appDelegate = (CardsAppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate toggleCardAndDeckView];
}
I tried it in the willRotateToInterfaceOrientation, willAnimateSecondHalfOfRotationFromInterfaceOrientation and didRotateFromInterfaceOrientation methods also with the same basic results.
My thoughts had been to set the new shown view's bounds to bounds of the container view, but the container view's bounds are always null!
I've seen this done before in videos so I know it works, but any help would be greatly appreciated.
Thanks,
Charlie