Phonegap不能旋转方向?

时间:2012-08-19 19:29:37

标签: ios cordova

我不知道为什么,但是当我旋转iPhone时,我的PhoneGap应用程序没有旋转屏幕。发布代码是没用的,因为它不适用于最简单的代码:<div>Hello World!</div

我也检查了方向设置: enter image description here enter image description here

这是一个例子(在实际设备上也是如此): enter image description here

2 个答案:

答案 0 :(得分:3)

对我来说同样的问题。我解决了它在我的代表上为iOS6添加以下行:

- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
    NSUInteger supportedInterfaceOrientations = (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationLandscapeLeft) | (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationPortraitUpsideDown);

    return supportedInterfaceOrientations;
}

另外,在主控制器上添加:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return true;
}

答案 1 :(得分:0)

更改classes文件夹

上的MainViewController.m
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    //return [super shouldAutorotateToInterfaceOrientation:interfaceOrientation];
     return true;
}

并且仍然在AppDelegate.m上的类文件夹

- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
    // iPhone doesn't support upside down by default, while the iPad does.  Override to allow all orientations always, and let the root view controller decide what's allowed (the supported orientations mask gets intersected).
    NSUInteger supportedInterfaceOrientations = (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationLandscapeLeft) | (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationPortraitUpsideDown);

    return supportedInterfaceOrientations;
}