English 中文(简体)
与导航控制器应用程序中的2个用户界面监视控制器的定向问题
原标题:Issue with orientations of 2 UIViewcontrollers in navigation controller application

I have a tabbar application. And the item of first tab is Navigation Controller. Navigation controller has 4 items in his stack. I want to provide rotation. But in tabbar application it s the problem, that s why I created my own tabbarcontroller and override the method:

@interface RotatingTabBarController : UITabBarController

@end

@implementation RotatingTabBarController

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    if([self.selectedViewController isKindOfClass:[UINavigationController class]]){
        BOOL f = [[(UINavigationController*)self.selectedViewController visibleViewController] shouldAutorotateToInterfaceOrientation:toInterfaceOrientation];
        return f;
    } else {
        BOOL f = [self.selectedViewController shouldAutorotateToInterfaceOrientation:toInterfaceOrientation];
        return f;
    }
}

@end

在那之后,如果我提供适当的 UI Interface 支持, 我的控制器将支持自动旋转。 但是没有我自定义的旋转塔巴控制器, 这似乎是不可能的 。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

The problem is: When I push FirstViewController in navigation controller in shouldAutorotateToInterfaceOrientation of this viewcontroller I provide only portrait orientation, but when I push SecondViewController (I provide there both portrait and landscape orientation), if current interface orientation of SecondViewController is landscape and I press back button (SecondViewController pop from stack and FirstViewController appears), the orientation of FirstViewController is landscape. But in shouldAutorotateToInterfaceOrientation method I provide only portrait orientation for him.

最佳回答

我用模式窗口和隐藏后按键 以Landscape 方向。 它解决了问题 。

问题回答

事实上,您不应该将UITABBA 主计长课程分类为子类。

UITabBar 主计长级执行专门的查看控制器,该控制器管理无线电式选择界面。 此类不用于子分类 。

发自UITabBarconcentle reference

如果您查看控制器, 控制器将覆盖

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation

方法,它应该是罚款。

我认为,支持某些观点的景观定位和一些非应用软件中的定位并不是一个好主意。

您已经发现原因了, 如果用户按回按钮时, 在风景模式下按回按钮呢?

在这里应该做什么, 旋转到脚脚下, 而装置有景观方向?

如果您想要这样做, 无法轻易地强迫设备改变方向。 您必须处理您使用变换的视图方向 。

您有可能支持使用模型视图控制器的视图的不同方向, 该控制器不在导航控制器的堆叠中。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签