问题描述
我正在使用iOS6设备xcode 4.5和美洲狮山在我的应用程序中,我开始使用纵向模式(3个屏幕).但是第4个屏幕应该在横向,并且应该支持横向左&风景不错.
Am using iOS6 device xcode 4.5 & mountain lion mac.And in my app am starting in portrait mode(3 screens).But 4th screen should be in landscape and should support landscape left & landscape right.
大多数说明都显示了如何旋转.
Most of the explanations are shown how to rotate.
在appddelegate中正在使用
in appddelegate am using
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
navigationController.navigationBar.tintColor = [UIColor blackColor];
// Set RootViewController to window
if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
{
// warning: addSubView doesn't work on iOS6
[self.window addSubview: navigationController.view];
}
else
{
// use this mehod on ios6
[self.window setRootViewController:navigationController];
}
}
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if(self.shouldRotate ) //shouldRotate is my flag
{
self.shouldRotate = NO;
return (UIInterfaceOrientationMaskLandscapeRight);
}
return (UIInterfaceOrientationMaskPortrait);
}
以及在我的视图控制器中应该是横向的并且正在使用
and in my view controller which should be landscape and am using
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
appDelegate.shouldRotate = YES;
// Custom initialization
}
return self;
}
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
在我的视图控制器中,正在使用的potrait正常工作
In my viewcontrollers which are potrait are working correctly in which am using
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
任何人都可以建议这样做
can any one suggest to do this
预先感谢
推荐答案
这对我有用我删除了NavigationController并进行了如下更改
This is working for meI removed NavigationController and changed as follows
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
self.viewController = [[PlashViewController alloc] initWithNibName:@"PlashViewController" bundle:nil];
}
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
我的应用程序如下将这种方法放置在我的视图控制器中在plist和target中,我指定了三个方向,例如portrait,landscapeleft和landscaperight以纵向显示视图
im my app am placed this methods in my view controllers as followsand in plist and target i specified three orientations like portrait , landscapeleft and landscaperightto show view in portrait
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
以横向显示视图
- (BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
这篇关于应用中间的iOS6中的横向模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!