- 1.界面旋轉(zhuǎn),MainScreen的寬高不變,鍵盤位置不變
'''
CGFloat duration = [UIApplication sharedApplication].statusBarOrientationAnimationDuration;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:duration];
self.view.transform =CGAffineTransformMakeRotation(M_PI/2);
[UIView commitAnimations];
'''
2.界面旋轉(zhuǎn),MainScreen的寬高改變,鍵盤位置不變
復(fù)制代碼
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
SEL selector = NSSelectorFromString(@"setOrientation:");
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
[invocation setSelector:selector];
[invocation setTarget:[UIDevice currentDevice]];
int val = UIInterfaceOrientationLandscapeRight;
[invocation setArgument:&val atIndex:2];
[invocation invoke];
}
復(fù)制代碼
3.界面旋轉(zhuǎn),MainScreen的寬高改變,鍵盤位置改變
a.General—>中勾選Lnadscape Left/Lnadscape Right
Pasted Graphic.tiff
b.控制器中實(shí)現(xiàn)以下兩個(gè)方法:
復(fù)制代碼
// 支持設(shè)備自動(dòng)旋轉(zhuǎn)
- (BOOL)shouldAutorotate
{
return YES;
}
/**
*? 設(shè)置特殊的界面支持的方向,這里特殊界面只支持Home在右側(cè)的情況
*/
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeRight;
}
復(fù)制代碼
PS:如何判斷當(dāng)前是否橫屏,一下3個(gè)方法都可以
self.interfaceOrientation(iOS 2.0~8.0)
[UIApplication sharedApplication] statusBarOrientation]
[[UIDevice currentDevice] orientation]