• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

iphone - navigationController 推送 ViewControllers 不会自动旋转

[复制链接]
菜鸟教程小白 发表于 2022-12-12 16:39:58 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我很难让导航 Controller 正确自动旋转。显示将在初始 View ( Root View Controller )上自动旋转,但不会在任何被推送的新 View 上旋转。它保持初始 View 在推送时的 View 方向。

在我的 App Delegate 中,我有一个导航 Controller 并推送它的 View 。

[window addSubview:navigationController.view];
[window makeKeyAndVisible];

在 Root View Controller 中,我允许所有方向,并将其他 View 推送到 Controller 的堆栈中。

- (BOOL)shouldAutorotateToInterfaceOrientationUIInterfaceOrientation)interfaceOrientation {
     return YES;
}

ParkingListController *parklc = [[ParkingListController alloc] autorelease];
[[self navigationController] pushViewController:parklc animated:YES];

我看到“是的,我们应该!”在新 View 加载时记录一次,但在设备实际旋转时不会触发。

- (BOOL)shouldAutorotateToInterfaceOrientationUIInterfaceOrientation)interfaceOrientation
{
    NSLog(@"Yes, we should!");
    return YES;
}

我没有任何初始化覆盖,并且 info.plist 列出了所有四个方向。

我错过了什么?谢谢!

编辑 2011-07-07:

奇怪的是,当您从表格 View 中选择一个项目时, map View 会自动旋转!为什么它来自的table view不能旋转?



Best Answer-推荐答案


您正在使用 UINavigationController,它应该返回 true 以进行旋转。请扩展 UINavigationController 并使用 Interface builder 中的扩展类。

#import <Foundation/Foundation.h>
@interface IRUINavigationController : UINavigationController {
}
@end

#import "IRUINavigationController.h"
@implementation IRUINavigationController
- (void)willRotateToInterfaceOrientationUIInterfaceOrientation)toInterfaceOrientation durationNSTimeInterval)duration{
    [self.visibleViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
- (BOOL)shouldAutorotateToInterfaceOrientationUIInterfaceOrientation)interfaceOrientation {
    return YES;
} 
@end

我用过很多项目,而且效果很好。

关于iphone - navigationController 推送 ViewControllers 不会自动旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6601983/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap