Ipad方向效果不佳 [英] Ipad orientation is not working well

查看:88
本文介绍了Ipad方向效果不佳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am creating an application with Landscape Right orientation. For that I set the Initial interface orientation property in info.plist file. Then in every view I handled

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

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

It works fine in simulator but in device its behave differently. My first view is in proper orientation. There is is popover which display another view that comes in portrait mode. Still my status bar is in Landscape Right..

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

For navigating from one view to another view I am using..

self.window.rootViewController = self.myNav;

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

I have multiple navigation Controller and adding those using the upper code. I am not getting what is the problem.

任何帮助都将不胜感激。

Any help will be appreciated.

编辑:我用过

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 

我从来没有在模拟器中遇到这个问题,但是在设备中而不是每次都这样。我也使用支持的界面方向(iPad)并设置横向(右主页按钮) <$ c $的值c> item0 。

I never get this issue in simulator but getting this in device and not every time. I have used Supported interface orientations (iPad) too and set Landscape (right home button) value for item0.

提前谢谢

推荐答案

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

You need to set the "Simulated Metrics > Orientation" property of your top view (in all your xib files) to be "Landscape". The default is portrait.

问题在这里得到了很好的回答 - 适用于iPhone或iPad的横向模式

The question was answered pretty well here - Landscape Mode ONLY for iPhone or iPad .

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

I also have an app that like yours only supports UIInterfaceOrientationLandscapeRight. I haven't run into any orientation issues so far. I only have one UIViewController under the window. This UIViewController has its own UITabBar that I use to change pages. So, we change pages differently. I set my UIViewController using the rootViewController property of the window just like you, but again I only have one.

此外,我从来没有做过[[UIDevice]这样的事情。 currentDevice] beginGeneratingDeviceOrientationNotifications]调用你包含的内容。由于您只支持LandscapeRight方向,因此您无需收到有关更改的通知。

Also, I never had to do anything like the [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications] call that you included. Since you only support LandscapeRight orientation, you shouldn't care to be notified of changes.

编辑

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

I created a sample project, which I can post if necessary, and I think I may know your problem. First - do you only encounter the sizing issue inside popovers? If so, then I don't think orientation is throwing you off but the popover itself. My sample project has 3 view controllers. The first loads the second by changing the window's rootViewController. That worked fine. The second view controller has a button to open a popover. This will show up wrong unless you set the contentSizeForPopover on the view controller as shown below:

- (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中视图的大小。

See if this fixes your problem. If it does, there are other ways to control the popover size, but this is just what I typically do. However, just know that the PopoverController ignores the size of the view in the viewcontroller you load.

这篇关于Ipad方向效果不佳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆