0

在我的應用程序中,我添加了UITabBarController * rootController;如何在iPad中自動旋轉?

in didFinishLaunchingWithOptions我完成了這段代碼。 爲我寫

WaylistController *waylistNavigationControllerTemp = [[WaylistNavigationController alloc] initWithNibName:@"WaylistNavigationController" bundle:nil]; 
     self.waylisyViewController = waylistNavigationControllerTemp; 
     UINavigationController * waylistNavigationController = [[UINavigationController alloc] initWithRootViewController:waylisyViewController]; 
     [waylistNavigationControllerTemp release]; 

WayRoomController *wayRoomNavigationControllerrTemp = [[WayRoomNavigationController alloc] initWithNibName:@"WayRoomNavigationController" bundle:nil]; 
     self.WayRoomViewController = wayRoomNavigationControllerrTemp; 
     UINavigationController * wayRoomNavigationController = [[UINavigationController alloc] initWithRootViewController:WayRoomViewController]; 
     [wayRoomNavigationControllerrTemp release]; 


rootController.viewControllers = [NSArray arrayWithObjects: WaylistNavigationController,//0 
            WayRoomNavigationController,//1      
            nil] 
[rootController setSelectedIndex:0]; 

這個我沒有得到自動定向總是隻得到愛國者。任何人請幫助我?

回答

0

把這個放在你需要的方向的控制器類中。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
// Return YES for supported orientations 
    if((interfaceOrientation == UIInterfaceOrientationPortrait) || (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) || (interfaceOrientation == UIInterfaceOrientationLanscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight)) 
    return YES; 

} 

還要確保在您的項目設置中,您已啓用所有方向。 在您的.xib文件中,使用自動調整來縮放這兩個方向。

0

檢查.plist文件中支持的接口方向的設置..