UINavigationController 作为 UISplitViewController 的详细视图

发布于 2024-08-27 17:16:16 字数 1228 浏览 8 评论 0原文

我将导航控制器设置为分割视图控制器的详细视图(NewFeedsNavigationController 继承自 UINavigationController)。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    masterViewController = [[MasterViewController alloc] initWithStyle:UITableViewStylePlain];
    UINavigationController *masterNavigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
    NewsFeedsNavigationController *newsFeedsNavigationController = [[NewsFeedsNavigationController alloc] initWithCategories];

    splitViewController = [[UISplitViewController alloc] init];
    masterViewController.splitViewController = splitViewController;
    splitViewController.viewControllers = [NSArray arrayWithObjects:masterNavigationController, newsFeedsNavigationController, nil];
    splitViewController.delegate = newsFeedsNavigationController;


    // Add the split view controller's view to the window and display.
    [window addSubview:splitViewController.view];
    [window makeKeyAndVisible];

    return YES;
}

事实上,导航控制器在纵向方向上工作得很好,但在横向方向上有点奇怪。当在层次结构中导航回来(朝向根视图)时,我总是必须在每个视图中点击两次。第一次点击时,可见视图将从堆栈中弹出,第二次点击时,导航栏会转动。通常,两者同时发生。我不知道出了什么问题。

I set up a navigation controller as detail view of a split view controller (NewFeedsNavigationController is inherited from UINavigationController).

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    masterViewController = [[MasterViewController alloc] initWithStyle:UITableViewStylePlain];
    UINavigationController *masterNavigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
    NewsFeedsNavigationController *newsFeedsNavigationController = [[NewsFeedsNavigationController alloc] initWithCategories];

    splitViewController = [[UISplitViewController alloc] init];
    masterViewController.splitViewController = splitViewController;
    splitViewController.viewControllers = [NSArray arrayWithObjects:masterNavigationController, newsFeedsNavigationController, nil];
    splitViewController.delegate = newsFeedsNavigationController;


    // Add the split view controller's view to the window and display.
    [window addSubview:splitViewController.view];
    [window makeKeyAndVisible];

    return YES;
}

As a matter of fact the navigation controller works splendidly in the portrait orientation but kind of freaks out in landscape orientation. When navigating back in the hierarchy (towards the root view) I always have to tap twice per view. Upon the first tap, the visible view is popped from the stack and upon the second tap, the navigation bar turns. Usually, both happen at the same time. I have no idea what is going wrong.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖伴 2024-09-03 17:16:16

我错了。错误行为在最新版本中仍然存在,但我找到了适合我的情况的解决方案。您不得派生自定义 UINavigationController 子类。甚至在视图控制器程序员指南中也是这么说的。遵循这个限制,我能够解决我所有的问题。

I was mistaken. the erroneous behavior persists in the latest release, but I found the solution for my case. You must not derive a custom UINavigationController subclass. It even says so in the view controller programmers guide. Following that restriction I was able to solve all my issues.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文