problem with presentModalViewController
If my iPad is in Landscape mode and presentModalViewController is called the view automatically turns into portrait mode. Any solutions?
UIViewController * start = [[UIViewController alloc]initWithNibName:@"SecondView" bundle:nil];
start.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
start.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:start animated:YES];
In SecondView I've already added:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return Y开发者_如何学PythonES;
}
The problem is your sample code is creating UIViewController instead of your actual derived class. In other words instead you should be creating your controller like this:
SecondViewController *start = [[SecondViewController alloc]initWithNibName:@"SecondView" bundle:nil];
I'm assuming your view controller class is called "SecondViewController" because you were loading a nib by a similar name.
If you don't provide the right instance there is no way your delegate methods can be called.
your UIViewController 'start' must override to let it appear in right orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations.
return YES;//UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
I got this problam just now. And I solve it by this way. Hope this can help you too.
There must be something else going on because defining in IB doesn't work for me either. Is the original OP using a splitViewController?
精彩评论