Run time viewcontroller - objective-c

I am creating an app with a tab bar. However, when the app starts, I don't want it to display the tab bar. Instead I would like to show a login page. After a successful log in, the tab bar based application should be shown.
Is this possible in code? I did it with Interface Builder.

Just create a Window-based Application and create a ViewController with a TabBar that you can show once login is successful.

Modal view controllers is the way you can do what you want. As it is said in the documentation
Modal view controllers are a tool that
you have at your disposal for
interrupting the current workflow and
displaying a new set of views.

Related

UI Tab Bar added to Storyboard not showing up when I build the App

I have an iOS App. I currently have an existing View Controller. I manually added a UI Tab Bar to it using the storyboard.
I added the UITabBarDelegate and implemented the corresponding functions required tabBar:tabBar didSelectItem:item.
I've also connected the delegate of the Tab Bar to the view controller itself.
However, when I build, the Tab Bar completely does not show up at all.
I know you can just use a Tab Bar Controller, but I need to add the Tab Bar to it, and use the Tab Bar to modify content of the view itself. (specifically it acts as a filter for a table view) So, it doesnt make sense to create 4 exact same Views to hook up to a UI Tab View Controller
What am I doing wrong?
I found out what's wrong.
It turns out, I had completely successfully implemented the UITabBar. What happened was that I was testing on an IPhone 4. As such, it bled out of the screen and could not be seen. Adding constraints fixed it.

When should I create a new window instead of using many different views?

You create a window, and inside the window you create many views, but how many windows do you create per app?
Say you have a login screen, a register form screen, and a dashboard screen.
So do you create:
One window and many views for the login and register screens and one window for the dashboard?
One login window with login view, one Register window (with Register screen view 1, register screen view 2, and register screen view 3), and one dashboard window (with many views)?
Furthermore, do you always need a view? If it's just one screen, can't you just create one window and add buttons, labels, and other things?
EDIT: according to apple... its 1 controller 1 view? https://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/CombiningViewControllers/CombiningViewControllers.html
The convention is to have only one Window which is declared in your AppDelegate. Inside of windows you add ViewControllers which can handle all your additional views. So you'd create a LoginViewController and a RegisterViewController.
Usually multiple windows are only needed for things like creating an alert (UIAlertView is its own UIWindow) that would be on top of all other views, but even this can be achieved by using keyWindow.

iOS presenting modal and navigation controller based views

I'm building an application for the iphone that uses both modal views and navigation-controllers. In my case, the initial screen is a table view within a navigation controller, and if the user clicks on the "+" button, they get a new screen that appears in a modal view sliding up from the bottom of the screen that will allow them to add a new record. Within this modal view I want to have a button that will allow them to select from a list of options.
To provide a quick example, take a look at this screenshot from the Apple documentation: https://developer.apple.com/library/ios/DOCUMENTATION/UserExperience/Conceptual/TableView_iPhone/Art/ui_navbarpurposes.jpg. If you look at the "Repeat" option in the second view, that's what I want to emulate -- the user will click on the option and a new view (not a action sheet) will load allowing them to select from a list.
Ideally, I would want this new option screen to slide in from the right like a new view was added to the navigation controller stack. However, since add record screen is a modal view, I can't do that, can I? Or would my modal view need to load my add records view embedded within a new navigation controller?
Hopefully I'm explaining this clearly enough. Sorry for any confusion!
Your last thought is the way to go: you need to add a navigation controller to your modal view, and then when they tap the table view row, you just push your next view onto the navigation stack.

iOS: Restoring the previously visible view when the app returns to the foreground?

I'm developing an iPhone (iOS 5+) app using storyboards. The first screen of the app is a splash/login screen that checks for Facebook credentials and enables you to read and accept Terms And Conditions. In case there are valid stored credentials and the TOC has been previously accepted, this view automatically makes a modal segue (using a cross dissolve effect) to the first "real" application view, a tab bar controller with three tabs.
I'm currently implementing backgrounding and foregrounding logic. The problem is that when pressing the home button and then coming back, the login screen is briefly shown before the correct pre-backgrounding view is restored. (The Default.png of the app is of the login screen background, so it might be either that or a backgrounding-time screenshot of the actual login screen; I haven't tested replacing Default.png yet to tell the difference.)
Why is this? As far as I can tell, backgrounding the app should just take a screenshot of the view that is visible on the screen when, say, hitting the home button, and restore that prior to restoring the actual view functionality when coming back to the foreground. In this case that would be one of the tabs of the tab bar controller. Is the modal segue between the login screen and the tab bar controller the culprit here, or something else?
(I've always felt that the cross dissolve modal segue from the login screen to the first "useful" screen is a bit dirty, since IMHO a modal segue seems to imply that what your segueing to is something you'll later dismiss to get back to the "from" screen. What I'm doing now is just leaving the target of the modal segue visible indefinitely. If that is the problem here, I'd love it if someone would suggest a better method of displaying, transitioning away from and "jettisoning" the login screen.)
OK, turns out this was just a simulator/device discrepancy regarding Default.png. This comment on another question made me think to check. Time to file a bug report.
If I recall correctly, Apple has some old demo code which "remembers" which view a navigation controller was showing before it went into the background.
By way of disclaimer, I haven't worked with storyboards, so I don't know the specifics of doing what you're trying to do.
If it were me, I'd create the view controller or controllers at launch, and then only add the login screen if deemed necessary by the app delegate's logic. Only then, after setting up the view hierarchy, do I present everything.
This accomplishes two things. My login screen only exists and is visible if necessary. Additionally, the login screen won't flash unessecarily. Oh, and as a third benefit, you can present any view you like.
I'd suggest, assuming the aforementioned demo code doesn't work for you, that you'll want to save some sort of reference, tag, or ID of the currently visible view in NSUserDefaults and read that out when setting up your view hierarchy on launch.

tab bar project with login screen

I am creating a tab bar controller project but also want to have a login screen before showing this. i also want a settings screen and info screen to be available to view from the login screen. if login is successful, then show the tab bar view. also to log out from the tab bar view.
what is the best way of doing this? what type of project and how to do the login screen?
any help would be much appreciated!
first of all create the viewbased project.In the first viewcontroller add the login screen.After that in loginscreenxib create the object of tabbarcontroller.