我只想在标志 enableRotation=1 时才允许界面更改。我一直在搞乱所有的旋转方法,但一无所获。
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
enableRotation=0;
currentOrientation=fromInterfaceOrientation;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
NSLog(@"enable rotation call %i\n",enableRotation);
if(enableRotation)
{
if ((interfaceOrientation== UIInterfaceOrientationPortrait) ||
(interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
||(interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)||(interfaceOrientation == UIInterfaceOrientationLandscapeRight)
)
{
return YES;
}
}
else if (interfaceOrientation==currentOrientation){
return YES;
}
return NO;
}
这就是我用来显示备用视图的内容....
- (void)orientationChanged:(NSNotification *)notification
{
if (UIDeviceOrientationIsPortrait(deviceOrientation))
{
[self performSegueWithIdentifier:@"DisplayAlternateView" sender:self];
isShowingLandscapeView = NO;
// enableRotation=0;
NSLog(@"Rotation disabled\n");
}
else if (UIDeviceOrientationIsLandscape(deviceOrientation) &&
!isShowingLandscapeView)
{
[self dismissViewControllerAnimated:YES completion:nil];
isShowingLandscapeView = YES;
// enableRotation=0;
NSLog(@"Rotation disabled Change to Landscape\n");
}
}