Where should I present Modal View Controller? - iphone

I have an application with a UITabBarController at its top level. I track which tab a user is on and store it so that when they reopen the application they are on the tab they were on when it was closed. So there is no default tab when the app starts up.
I have a modal screen that shows first every time the app starts. It doesn't matter which tab was saved, the user is always presented with this view.
Where should this modal view be presented from? The logical thing would be to have the UITabBarController present it as it is the rootViewController, but Apple discourages subclassing UITabBarController. Another approach would be to have a UIViewController as the rootViewController that would handle the presentation, but Apple insist that UITabBarController should be the rootViewController.
So how should I deal with this?

If you start with a window-based application  and first set your viewController as rootViewController and then, after you're done with this viewController, set the tabBarController as rootViewController, i think you don't have problems.

Related

iPhone TabBar Controller Usage

I want make a typical tabbar based application.
And I want to insert login view on startup before main tabbar is shown.
I tried to insert TabbarController in main view, but cannot find appropriate code. All sample code I found is insert TabbarController on startup. (in Delegate file)
My fellow suggest create toolbar on startup but hide it at login view, but I am not sure if this is a general method or not.
In this case, what is a 'recommanded' handling method of TabbarController ?
A simple solution would be to
1-Add the tab bar to UIWindow in the appDelegate as is suggested by apple.
2-then add a UINavigationController in tabbar using tabbarController.viewControllers=[NSArray arrayWithObject:yourNavController];
3- Now after alloc init on your login controller write this code before pushing it to the navigation controller of the tabbar
yourLoginController.hidesBottomBarWhenPushed=true;
4- push yourloginViewController to the navigation controller of the tabbar.
5- After authentication before pushing your MainviewController instance on the navigation set it like this
MainviewController .hidesBottomBarWhenPushed=false;
I hope these five simple steps will do the magic for you cheers :)
Please let me know if it helps you.Thanks
The approach I use for login screens which works great is:
prepare and show the regular main screen (tab bar controller with whatever initial VC you want to use)
immediately present the login screen modally (without animation) from the tab bar controller (which will obscure the tab bar controller, which is what you want)
make the login screen the startup image

Genuine UITabBarController and UINavigationController architecture clarity

I have a TabBarController in which I have 5 tabs to access. In one of the tabs I have a Navigation Controller and then the stacks. The navigation controller is being set through IB at this point and the viewcontroller in there is also. Now my concern is that, how can I redraw something based on that particular tabbar as the tableview is not reloading the data since viewWillAppear is not being called when I am in that particular tab.
I am trying to analyze as what is the best way to trigger being in such active tab to trigger such routine. I tried tabbarcontroller didselectviewcontroller delegate pattern in my viewcontroller, and have linked the delegate in my IB from the navigation controller to tabbarcontroller.
However such delegate is not getting triggered when I am in that particular tab item. Any suggestions at this point will be really great?
Thanks

What is the pattern for an Iphone app with both a View Controller and Tab Bar Controller?

I am trying to write an iPhone app that has both a UITabBar controller (and its associated views) and a plain vanilla view controller that is not part of the TabBar (i.e. an initial config page that only gets displayed the first time the app is run).
I am able to put a Tab Bar Controller and a View Controller in MainWindow.xib and shuffle between the two in the app delegate.
While this works I'm wondering if this is the best way to be implementing this.
It doesn't feel very "MVC-ish" to me but I think the two different controllers both need to be root (?)
I don't know how else I would do it.
If the config page is really only a "run once" affair, you could just pop it as a modal view from within the tab bar controller via the presentModalViewController:animated: method. (If on the other hand the config page is ever likely to be required in the future, I'd just add it as another option on the UITabBar.)
You would make the tabbarcontroller the default view. And present the viewcontroller modally in viewWillAppear or similar method. Then when you want to switch to the tabbar, you'd dismiss the modal view controller.

how to write code for the log out in my off line iphone app

hi friends i am using UIButton for "LOGOUT" in a tabBarController having Five tabs like(Tab1,Tab2...) in IB OUTLET
i have logout page in "Tab5", when i clicks logout
i am removing page from super view and Showing "login PageView Controller",but when i log in again
it going to Same log out page...but i need to do two things like
1)Initialize Tabbar again and
2)i want to show Tabbar from first tab, like Tab1
can help anyone...
Thx in Advance
I think the question is, how do you write code to "log out" your app and clear all of the data in all of the views across a tab bar controller?
If I can help translate, I think the scenario is essentially this:
He has an app with two view controllers in MainWindow.xib, a UIViewController and a UITabBarController. Both are hooked up to IBOutlet properties on his app delegate. When the app loads, the app delegate instantiates both controllers automatically, and he shows the UIViewController with a login form.
When the user logs in, it uses some technique to hide the UIViewController and show the UITabBarController.
On a view in one of the tabs in the UITabBarController, there is a logout button. When the button is tapped, it removes the UITabBarController from the superview and shows the login UIViewController.
When the user logs in again, the UITabBarController has remained in memory, so the state has not changed since logging out. All of the data on all of the tab views needs to be reset.
What's the best practice to scrap the UITabBarController and reinstantiate it?
You can't use the following, since MainWindow.xib contains your app delegate, and another UIViewController, not just your UITabBarController:
tabBarController = [[UITabBarController alloc] initWithNibName:"MainWindow" bundle:nil];

Customizing "More" Tab Bar

I am using a tab bar (UITabBarController) on my app and I wish to customize the appearance of the table that appears when you click the more button.
My app customized with a background image on every page. But image is not displaying when i click more button.
Any ideas?
If you're actually using UINavigationController embedded within a UITabBarController then the more item is a UINavigationController which exists as a property of your UITabBarController with the name moreNavigationController. You can manipulate it in methods of your UITabBarController just as you can any other UINavigationController.
HTH, Pedro :)
It sounds like you have a UINavigationController as the main VC of your app, and a UITabBarController as one of the VC's on its stack.
I believe Apple actively discourages people from doing this in their apps, and so do I. It is never done in the iOS itself, and I have never seen it in any third-party apps either, so users will probably be confused.
I think you should embed the UINavigationController inside the UITabBarController instead of the other way around, or you could just choose to use another way of showing what you want to show.
see UITabBarController's 'More' navigation controller disappears under UINavigationController