// 初始设定不可旋转
NSUInteger lock = UIInterfaceOrientationMaskPortrait;
// 按钮设定
- (IBAction)turnBtnClick:(id)sender{
UIButton *lockBtn = (UIButton *)[self.view viewWithTag:103];
if (lock == UIInterfaceOrientationMaskAllButUpsideDown) { //禁止转动
lock = UIInterfaceOrientationMaskPortrait;
[lockBtn setTitle:@"LOCK" forState:UIControlStateNormal];
} else { //可转动
lock = UIInterfaceOrientationMaskAllButUpsideDown;
[lockBtn setTitle:@"UNLOCK" forState:UIControlStateNormal];
}
}
// 旋转响应
- (NSUInteger)supportedInterfaceOrientations{
return lock;
}