2014-06-25 36 views

回答

1

添加类变量

Bool isInLandsCapeOrientation; 

viewDidLoad中

使用这个标志

isInLandsCapeOrientation = false; 

添加以下功能

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
if (!isInLandsCapeOrientation) { 
    return (UIInterfaceOrientationIsPortrait(interfaceOrientation)); 

}else { 
    return (UIInterfaceOrientationIsLandscape(interfaceOrientation)); 
} 
} 

从纵向改变方向为横向,让它发生在一个按钮动作

- (IBAction)changeOrientationButtonPressed:(UIButton *)sender 
{ 
isInLandsCapeOrientation = true; 
UIViewController *viewController = [[UIViewController alloc] init]; 
[self presentModalViewController:viewController animated:NO]; 
[self dismissModalViewControllerAnimated:NO]; 
}