开发者

Need help with the tab bar and tab bar controller

My iPhone app has a login page (shocker i know) but when the 开发者_运维技巧user successfully logs in, I want a view with a tab bar at the bottom to load and populate the buttons with data from the specific user. I can not find any tutorials on the tab bar, just the tab bar controller and from what i've read and seen, you can only have a tab bar controller on the MainWindow.xib. If thats not true, please show me how to have a tab bar controller on a view other that the main window. This is driving me nuts. Beer on me for a solution. Thanks


I have the same exact thing going on in my app and I can sympathize with you. There really isn't much to go on out there.

For me, it starts in your AppDelegate. I would validate the login info there, if it was good, push out the tabbarcontroller. If not, just present the logincontroller instead. It can be a tad tricky, but if you start there, you should be able to use everything else to get what you need.

Use the AppDelegate to determine which controller to push. When you push the login and it is good, call back to your appdelegate to push the tab bar controller and kill off the login.

Hope this helps. Good Luck.


You certainly can have a tab bar controller in other places besides MainWindow.xib. An example of one being created programattically, is in View Controller Programming Guide for iOS. See the section on Creating a Tab Bar Interface Programmatically.

Now, you've probably seen this already, but the point is even though Apple's example is in applicationDidFinishLaunching, you could do it anywhere you launch a view controller, like in response to a button click.

A few things to consider though:

  1. Tab bar view controllers aren't meant to be embedded inside a navigation controller (i believe it would give you errors). it's the other way around is recommended. It might make more sense to present a tab bar view controller modally.
  2. In your specific case, it sounds like the best thing would be to keep it simple by letting the tab bar be the root view controller in the main window after all, and having your login screen be automatically popped up after launch (i.e present it modally) then after proper login, dismiss the log in screen to reveal the tab bar controller that was there all along.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜