UINavigationController推送视图 [英] UINavigationController Push Views

查看:112
本文介绍了UINavigationController推送视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对不起 - 这可能是一个简单的问题,我是新的iPhone开发,仍然包装我的视图vs ViewControllers。

Sorry - this may be an easy question, I'm new to iPhone development and still wrapping my head around Views vs ViewControllers.

我有一个NavigationViewController和我可以在连接到Bar Button Item的RootViewController中使用以下方法推送Views:

I have a NavigationViewController and I can push Views using the following method in the RootViewController which is connected to a Bar Button Item:

- (IBAction)switch:(id)sender {
        NSLog(@"Swith...");
        LibraryViewController *varLibraryViewController = [[LibraryViewController alloc] initWithNibName:@"LibraryViewController" bundle:nil];
        [[self navigationController] pushViewController:varLibraryViewController animated:YES];
    }

我想从同一个视图上的按钮调用这个方法目前加载。基本上我想让顶部的栏按钮调用与视图上的按钮相同的方法。我想知道如何从ViewController加载的视图中调用ViewController中的方法。希望这是有道理的。

I want to call this same method from a button on the same view that is currently loaded. Basically I want to have the Bar Button at the top call the same method as a button on the view. I was wondering how to call a method in the ViewController from the view loaded from that viewController. Hopefully that makes sense.

我需要创建一个RootViewController的实例吗?我认为已经实例化。谢谢。

Do I need to create an instance of the RootViewController? I would think that would already be instantiated. Thank you.

推荐答案

您的RootViewController应该有自己的xib文件。在这个xib中,RootViewController由名为File's Owner的对象表示。您可以将视图上的按钮链接到文件所有者,方法与在MainMenu.xib中将内容链接到RootViewController的方式相同。

Your RootViewController should have its own xib file. In this xib, the RootViewController is represented by the object named "File's Owner". You can link buttons on the view to File's Owner the same way you can link things to RootViewController in MainMenu.xib.

这篇关于UINavigationController推送视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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