0
爲什麼UINavigationController AutoRotation在設備上不起作用?如何爲UinavigationController設置自動旋轉屬性?UiNavigationController Autorotation無法在設備上工作?
**BusinessCardAppDelegate.m**
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self.window makeKeyAndVisible];
RootView *rView=[[RootView alloc]initWithNibName:@"RootView" bundle:nil];
self.naviGationController =[[[UINavigationController alloc]initWithRootViewController:rView]autorelease];
[self.window addSubview:naviGationController.view];
return YES;
}
**RootView.m**
- (void)viewDidLoad
{
[super viewDidLoad];
self.title [email protected]"BusinessCard";
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationFunction:) name:UIDeviceOrientationDidChangeNotification object:nil];
}
-(void)orientationFunction:(NSNotification*)notification
{
UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
switch (orientation)
{
case UIDeviceOrientationPortrait:
/* AlertView Show*/
break;
case UIDeviceOrientationPortraitUpsideDown:
/* AlertView Show*/
break;
case UIDeviceOrientationLandscapeLeft:
/* AlertView Show*/
break;
case UIDeviceOrientationLandscapeRight:
/* AlertView Show*/
break;
default:
break;
}
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
爲什麼這不是在設備上工作,但在模擬器中工作正常?我不明白爲什麼這不起作用? 在此先感謝。