Ipad方向效果不佳

时间:2011-08-10 08:33:30

标签: ios ipad orientation

我正在创建一个具有Landscape Right方向的应用程序。为此,我在Initial interface orientation文件中设置了info.plist属性。然后在我处理的每个视图中

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

它在模拟器中工作正常但在设备中它的表现不同。 我的第一个观点是正确的方向。有一个popover显示另一个以纵向模式进入的视图。我的状态栏仍然在Landscape Right ..

用于从一个视图导航到另一个视图我正在使用..

self.window.rootViewController = self.myNav;

我有多个导航控制器并使用上层代码添加它们。 我没有得到什么问题。

任何帮助将不胜感激。

EDIT:我用过

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 

我从来没有在模拟器中遇到这个问题,但是在设备中而不是每次都这样。我也使用了Supported interface orientations (iPad)并为Landscape (right home button)设置了item0值。

提前致谢

2 个答案:

答案 0 :(得分:3)

您需要将顶视图(在所有xib文件中)的“模拟指标>方向”属性设置为“横向”。默认为纵向。

问题在这里得到了很好的回答 - Landscape Mode ONLY for iPhone or iPad

我也有一个像你这样的应用程序只支持UIInterfaceOrientationLandscapeRight。到目前为止,我还没有遇到任何方向问题。我只在窗口下面有一个UIViewController。这个UIViewController有自己的UITabBar,用于更改页面。所以,我们改变页面的方式不同我像你一样使用窗口的rootViewController属性设置我的UIViewController,但我只有一个。

另外,我从来没有做过你所包含的[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]调用。由于您仅支持LandscapeRight方向,因此您不应该注意更改通知。

修改

我创建了一个示例项目,如果有必要我可以发布,我想我可能知道你的问题。首先 - 您是否只遇到弹出窗口内的尺寸问题?如果是这样,那么我不认为方向会让你失望但是弹出本身。我的示例项目有3个视图控制器。第一个通过更改窗口的rootViewController来加载第二个。这工作得很好。第二个视图控制器有一个用于打开弹出窗口的按钮。除非您在视图控制器上设置contentSizeForPopover,否则这将显示错误,如下所示:

- (IBAction) showVC3InPopover
{
    UIViewController * vc3 = [[VC3 alloc] init];
    /** Set the contentSizeForViewInPopover property to determine how 
        large the view will be in the popover!  You can do this in the 
        init method(s) of the view controller if you prefer, it's just 
        easy to do here */
    vc3.contentSizeForViewInPopover = vc3.view.frame.size;
    [_popover release], _popover = nil;
    _popover = [[UIPopoverController alloc] initWithContentViewController:vc3];
    [vc3 release];

    [_popover presentPopoverFromRect:_showPopoverButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}

看看这是否可以解决您的问题。如果是这样,还有其他方法来控制弹出窗口大小,但这正是我通常所做的。但是,只要知道PopoverController就会忽略你加载的viewcontroller中视图的大小。

答案 1 :(得分:1)

您有多少次观看(或viewControllers)?您可能需要在所有这些视图中实现此方向逻辑??

相关问题