iOS 6 - (BOOL)应该没有调用导航控制器推送viewControllers的调用 [英] iOS 6 - (BOOL)shouldAutorotate not getting called for navigation controllers pushed viewControllers

查看:92
本文介绍了iOS 6 - (BOOL)应该没有调用导航控制器推送viewControllers的调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的应用 rootViewController navgationController

我发现
推送控制器的

I found that pushed controller's

- (BOOL)shouldAutorotate 未被调用。

- (NSUInteger)supportedInterfaceOrientations 仅调用一次。

我已在 xcode的项目摘要中正确检查(或 plist )用于windows所有方向支持。

I have checked correctly in xcode's project summary (or plist) for windows all orientation support.

我希望调用这些方法,因为有一些uicontrol定位代码,我想以编程方式执行方向更改。

I want these method to get called, as there is some uicontrol positioning code which i want to execute programmatically for orientation change.

我通过覆盖(类别)导航控制器的以下方法解决了这个问题

I solved this problem by overriding (category) navigation controller's following methods

-(BOOL)shouldAutorotate;

-(NSUInteger)supportedInterfaceOrientations;

我检查了哪个控制器被推送,因此在导航控制器的以下方法中调用了相应的推送控制器的uicontrol定位代码

I checked which controller is getting pushed and accordingly called respective pushed controller's uicontrol positioning code in Navigation controller's following method

(NSUInteger)supportedInterfaceOrientations;

这个工作正常,但我不认为这是正确的方法。请帮我解决更好的解决方案。

This is working fine but i dont think this is correct way. Please help me out for better solution.

推荐答案

你可以查看以下链接,你需要创建自定义导航来支持应该自动旋转

You can check the following link, you need to create custom navigation to support should auto rotate

http://mobileappdevpage.blogspot.in/2012/11/how-to-use-should-autorotateios-6-with.html

另一种方法是通过为.h文件创建UINaviagationController的类别

The other way you can do this by creating category of UINaviagationController

代码

@interface UINavigationController (autorotation)

-(BOOL)shouldAutorotate;
-(NSUInteger)supportedInterfaceOrientations;

和.m文件的代码是

@implementation UINavigationController (autorotation)

-(BOOL)shouldAutorotate
{

    UIInterfaceOrientation interfaceOrientation = [UIApplication sharedApplication].statusBarOrientation;
    [self.topViewController shouldAutorotate];
    return YES;

}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;

}
@end

这篇关于iOS 6 - (BOOL)应该没有调用导航控制器推送viewControllers的调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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