在iPad中开始横向定位?

时间:2013-02-08 10:15:39

标签: ios xcode ipad orientation landscape

我必须尝试使用​​iPad应用程序进行横向调整,以便在info.plist中进行一些更改

enter image description here AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];

    CGRect screenBound = [[UIScreen mainScreen] bounds];
    NSLog(@"screenBound:%@",NSStringFromCGRect(screenBound));

    return YES;
}

然后我从CGRect得到屏幕分辨率是screenBound:{{0,0},{768,1024}} 但我想要{{0,0},{1024,768}},如何做到这一点?请帮帮我

先谢谢

3 个答案:

答案 0 :(得分:0)

在.plist而不是UIInterfaceOrientation中使用UISupportedInterfaceOrientations,并将横向定位作为UISupportedInterfaceOrientations列表中的第一个。

答案 1 :(得分:0)

将此行代码放在AppDelegate.m

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationLandscapeLeft;
}

答案 2 :(得分:0)

可能有所帮助: 用这个方法写

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions


[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft];