简体   繁体   English

iPhone SDK如何使用分段控件显示的两个不同视图设置视图方向

[英]iPhone sdk how to set view orientation with two different views displayed by segmented control

I'm using a segmented control that has two segments. 我正在使用具有两个细分的分段控件。

  • When segment 1 is pressed, I display a view that contains a tableview of which I don't want landscape orientation, only portrait. 按下第1段时,我将显示一个视图,其中包含一个我不希望横向放置而是仅纵向的桌面视图。
  • When segment 2 is pressed, I display a different view of which I want to allow landscape orientation. 按下第2段时,我将显示一个我想允许其横向放置的视图。

So, I'm using the following code: 因此,我正在使用以下代码:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
   if (self.view == self.myFirstView)
      return false;
   else if (self.view == self.mySecondView)
      return true;
}

This all works nicely, except for the following condition: If the user selects segment 2, and then rotates the phone, the view goes into landscape mode. 除以下情况外,所有其他方法都很好用:如果用户选择了第2段,然后旋转了手机,则视图进入横向模式。 Then, while still holding the phone in landscape mode, the user presses segment 1. This displays the first view in landscape mode (I only want this view to be displayed in portrait mode). 然后,在仍将手机保持为横向模式的同时,用户按段1。这将在横向模式下显示第一个视图(我只希望此视图以纵向模式显示)。

So, the question is, how do I show the first view, but reset the view orientation to portrait? 因此,问题是,如何显示第一个视图,但将视图方向重置为纵向?

Any ideas? 有任何想法吗?

在view1中,获取方向,如果是横向,则将其切换为portratit。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM