带有 uinavigationcontroller 和 uitabbarcontroller 的 iPhone 应用程序
我是 iPhone 编程新手,我正在尝试构建一个具有 uinavigationcontroller 的应用程序,而 rootviewcontroller 是一个 uiviewcontroller,它基本上是一个登录屏幕,用户从登录屏幕移动到 uitabbarcontroller,它有 5 个选项卡,每个选项卡都是一个uinavigationcontroller 和每个导航控制器在导航栏中都有两个按钮,一个按钮带来消息视图,另一个按钮带来通知视图,每个视图都是一个 uiviewcontroller。
现在用户可以按每个选项卡上的消息按钮,消息视图将会出现,我想确保如果他按下第一个选项卡上的按钮然后转到另一个选项卡,那么消息视图将会消失并从内存中释放,当他按下新选项卡上的消息按钮时,将出现另一个消息视图。
我尝试在应用程序委托中创建单个消息视图,每次用户按下消息按钮以从应用程序委托调用方法时,然后在方法中我检查按下了哪个选项卡并将视图推送到所属的导航控制器该选项卡但无法正常工作。
I'm new to iphone programming and i'm trying to build an application that has a uinavigationcontroller and the rootviewcontroller is a uiviewcontroller that is basicly a login screen from the login screen the user moves to uitabbarcontroller that has 5 tabs and each tab is a uinavigationcontroller and each navigationcontroller has two button in the navbar one button brings a messages view and the other notifications view each view is a uiviewcontroller.
Now the user can press the message button on every tab and the message view will appear and i want to make sure that if he presses the button on the first tab and then goes to another tab then the message view will disappear and deallocated from memory and when he presses the message button on the new tab then another message view will appear.
I tried the create a single message view in the app delegate and every time that the user presses the message button to call a method from app delegate then in the method i check which tab is pressed and push the view to the navigation controller that belongs to that tab but that doesn't work properly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将登录视图嵌入 AppDelegate 中并根据需要显示它们。从那里您将加载 rootController,它应该是您的 tabBar。然后您可以在每个选项卡内加载导航控制器。每个选项卡一个。您可以从任何选项卡调用您的消息视图。只需确保以正确的方式分层控制器即可。
应用删除-->标签栏 -->导航控制器 -->个人观点
You can embed your login views inside the AppDelegate and show them as needed. From there you would load your rootController, which should be your tabBar. Then you can load up your navigation controller inside each tab. One for each tab. Your message view can be called from any of the tabs. Just need to make sure you layer your controllers the right way.
AppDel --> TabBar --> NavController --> Individual Views
您是否意识到可以替换窗口中的根视图控制器?您的应用程序委托的 -applicationDidFinishLaunching:withOptions: 方法可能会执行以下操作:
当您设置窗口的
rootViewController
属性时,窗口将添加该视图控制器的视图作为其自身的子视图。-applicationDidFinishLaunching:withOptions:
没有什么特别之处——它只是当应用程序完成加载并准备好开始工作时调用的委托方法。您可以像其他方法一样设置窗口的 rootViewController 属性,因此当您的登录视图控制器确定用户已成功登录时,它可以执行以下操作之一:Do you realize that you can replace the root view controller in a window? Your app delegate's
-applicationDidFinishLaunching:withOptions:
method probably does something like:When you set the window's
rootViewController
property, the window will add that view controller's view as a subview of itself.There's nothing particularly special about
-applicationDidFinishLaunching:withOptions:
-- it just happens to be the delegate method that's called when the app has finished loading and is ready to get down to business. You can set the window'srootViewController
property just as well from other methods, so when your login view controller determines that the user has successfully logged in, it can do something like one of the following:rootViewController
property itself