如何在iPad中自动旋转?

时间:2012-10-06 08:22:53

标签: xcode uiviewcontroller uinavigationcontroller uitabbarcontroller

在我的应用程序中,我添加了UITabBarController * rootController;

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];

为此我没有得到汽车东方总是只获得爱国者。任何人请帮帮我?

2 个答案:

答案 0 :(得分:0)

将它放在您需要方向的控制器类中。

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

}

还要确保在项目设置中启用了所有方向。 在.xib文件中,使用自动调整大小来缩放两个方向。

答案 1 :(得分:0)

检查.plist文件中的设置以获取支持的界面方向..