0

我有一个视图“MainView”,它有一个没有任何导航控制器的导航栏,而且,它有一个没有标签栏控制器的标签栏。每个标签栏项目都有自己的视图控制器。每次我单击选项卡栏项目时,它只会删除当前视图控制器并插入另一个视图控制器。

然后,某个标签栏项目有一个视图“listview”,这个视图中有一个uitableview,当我点击uitableview中的一个项目时,它会删除当前视图并添加另一个子视图“detailview”。但这一次,我想在当前视图上添加一个导航按钮,以便我可以返回“listview”。

如何从当前视图访问“MainView”上的导航栏?

4

1 回答 1

-1

It sounds like you are making the mistake of using only views when you should be making correct use of view controllers. If you are a new developer this is especially important to get right.

Your login screen should be a view controller, e.g. MyLoginViewController. This can initially be the rootViewController of your main window, or you can present it modally over your main content when the app launches.

After logging in, you can either replace the window's rootViewController with your main view controller, or dismiss the login screen if you presented it modally.

Your main view controller should be a UITabBarController, and if you want push/pop navigation with back buttons etc. you need to put a UINavigationController inside each tab, and then push the top-most view controller onto that.

This can all be done very easily using interface builder as well.

于 2012-06-29T09:41:15.777 回答