2012-12-31 35 views
0

我的方向设置为横向,iphone模拟器以横向模式加载和启动我的应用程序。由于ios6上面的代码以纵向模式而不是横向模式加载图像。请指教。仅在ios6中以纵向模式显示图片

编辑:问题从这里开始:

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    [self.view setBackgroundColor:[[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"480x320-background.png"]]]; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)anInterfaceOrientation{ 
    return anInterfaceOrientation==UIInterfaceOrientationLandscapeLeft || anInterfaceOrientation==UIInterfaceOrientationLandscapeRight; 
} 
+0

题外话:我建议使用ARC。 – dasdom

+0

这段代码看起来不错。该错误必须在其他地方。您是否已设置supportedInterfaceOrientations(http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/supportedInterfaceOrientations)? – dasdom

+0

我更新了代码。我刚刚发现问题在我最初发布的代码之前开始。 – Segev

回答

0

那个什么固定我的问题:在didFinishLaunchingWithOptions [window setRootViewController:headiPhone];

1

在iOS6的shouldAutorotateToInterfaceOrientation已被弃用。您必须使用supportedInterfaceOrientationsshouldAutorotate

0

要解决自动旋转问题iOS6的,请执行下列操作:

添加以下

if ([[UIDevice currentDevice].systemVersion floatValue] < 6.0) 
{ 
    // Note : addSubView doesn't work on IOS6 
    [window addSubview: viewController.view]; 
} 
else 
{ 
    // For IOS6, use this method 
    [window setRootViewController:viewController]; 
} 

而不是AppDelegate.m文件

[window addSubview: viewController.view]; 

里面RootViewController.m文件

//对于iOS6的,使用supportedInterfaceOrientations & shouldAutorotate代替shouldAutorotateToInterfaceOrientation

- (NSUInteger) supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskLandscape; 
} 

- (BOOL) shouldAutorotate 
{ 
    return YES; 
} 
0

在iOS 6中,旋转方法被改变。你应该实现这个方法,并返回YES。

- (BOOL) shouldAutorotate 
{ 
    return YES; 
} 
相关问题