Problem:
I have two view controllers loaded into the root view controller. Both layouts are displayed according to orientation changes. I switch between the two views using [UIView transformFromView: ...]. Both sub-choices work fine on their own, but if ...
- Views replaced
- Orientation changes
- Views replaced again
A View that was previously hidden has serious layout issues. The more I repeat these steps, the worse the problem.
Implementation Details
I have three viewControllers.
- Myappppcontroller
- A_ViewController
- B_ViewController
A B ViewControllers , UIWebView AQGridView . , , loadView A_ViewController...
- (void)loadView {
[super loadView];
UIImageView *bg = [[UIImageView alloc] initWithFrame:self.view.bounds];
bg.contentMode = UIViewContentModeCenter;
bg.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
bg.image = [UIImage imageNamed:@"fuzzyhalo.png"];
[self.view addSubview:bg];
CGRect webFrame = self.view.bounds;
webFrame.origin.x = 34;
webFrame.origin.y = 34;
webFrame.size.width = webFrame.size.width - 68;
webFrame.size.height = webFrame.size.height - 68;
projectView = [[UIWebView alloc] initWithFrame:webFrame];
projectView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self.view addSubview:projectView];
}
AQGridView B_ViewController .
. , AppViewController, ...
- (void)loadView {
[super loadView];
self.view.autoresizesSubviews = YES;
[self setWantsFullScreenLayout:YES];
webView = [[WebProjectViewController alloc] init];
[self.view addSubview:webView.view];
mainMenu = [[GridViewController alloc] init];
[self.view addSubview:mainMenu.view];
activeView = mainMenu;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(switchViews:) name:SWAPVIEWS object:nil];
}
, switchView,
- (void) switchViews:(NSNotification*)aNotification;
{
NSString *type = [aNotification object];
if ([type isEqualToString:MAINMENU]){
[UIView transitionFromView:activeView.view toView:mainMenu.view duration:0.75 options:UIViewAnimationOptionTransitionFlipFromRight completion:nil];
activeView = mainMenu;
}
if ([type isEqualToString:WEBVIEW]) {
[UIView transitionFromView:activeView.view toView:webView.view duration:0.75 options:UIViewAnimationOptionTransitionFlipFromLeft completion:nil];
activeView = webView;
}
}
, , , , , , , , -, .
- , . , ...
UPDATE:
, , , , . , , .

... .... ....
