I am trying to load a view with the shouldAutorotateToInterfaceOrientation
method, but I have a problem. When the device runs as landscape, I want to show the main view itself, and when when the devi开发者_JAVA技巧ce is portrait, load a custom UIView.
Here is my code:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
if ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft)|| (interfaceOrientation == UIInterfaceOrientationLandscapeRight))
//doesn't show main view !!
self.view;
else if ((interfaceOrientation == UIInterfaceOrientationPortrait) || (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown))
//works fine !
self.view = portraitView;
return YES;
}
I figured out !!!! just call the view with modal on a method
- (void) mainView {
screenTestViewController *mv = [[screenTestViewController alloc]initWithNibName:@"screenTestViewController" bundle:nil];
[self presentModalViewController:mv animated:NO];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
if ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft)|| (interfaceOrientation == UIInterfaceOrientationLandscapeRight))
[self mainView];
.
.
.
You should push your custom UIView in: willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
精彩评论