Presenting view from app delegate - iphone

I am working on a project in which I need to present login page each time the app enters fore ground from back ground. I wanted to present a model viewcontroller but Model view is not supported.
Is there any other way I can do this?

Register for UIApplicationWillEnterForegroundNotification. Once you get the notification, show your login view controller using [self presentmodelviewcontroller:view animated:YES];

Related

Change initial view controller after first launch of app

I have a two-view login to my app where a user enters two views worth of info. After the user has entered that info I want change which view is the initial view controller, and have the login view be a settings-like page.
How can I change the initial view controller after the user has passed a certain point in the app?
For one of my apps, where I did similar to this, I have my "main" view controller check on viewDidLoad for a setting in the default settings that would indicate if the user had signed in. If they hadn't, I immediately pushed the loginViewController without animation and the user filled in the appropriate forms. When that was dismissed, I reloaded the view in my main view controller.
My client liked the app and it looked nice.
If the user has already "passed a certain point", then what you change to can't be "initial" view controller, can it? The "initial" view controller is the view controller shown on launch.
Do you mean that you want a different view to appear first on subsequent launches? Then write something into the NSUserDefaults that you can check on subsequent launches so that you can start with a different window.rootViewController? Like this (changing all the names) in your app delegate's applicationDidFinishLaunching:
if ([[NSUserDefaults standardDefaults] valueForKey: #"loginDone"])
self.window.rootViewController =
[[UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil]
instantiateViewControllerWithIdentifier:#"secondVC"];
Or do mean that you just want to navigate away from the login stuff and never return? Then use a presented view controller and just never dismiss it.

Segue to Tab Bar Controller with performSegueWithIdentifier

I'm learning iOS and I'm working on what amounts to a Proof of Concept app in XCode 4.2. I essentially want to allow a user to enter a user/pass combo and if the user is in an array of objects, pass them on to the "Content" view, but if not, pass them on to the "Register" view.
In either case, since the app itself will be a tabbed app (though the login and register views are not tabbed), I need to be able to segue from a typical ViewController to a TabViewController.
- (void)logIn:(id)sender{
[self performSegueWithIdentifier:#"Content" sender:sender];
}
Currently, I have the app segueing to the proper ViewController, which is a TabBarController embedded in a NavViewController...but once it gets there...there are no tabs!!
What am I doing wrong?
Now you aren't loading TabBarController that's why you don't have any tabs.
What I suggest you:
In Log In ViewController you can also add "register" button, and place a segue from it to Register View Controller.
Add IBAction from log in button, which will check for log in and pass, and if it's OK load Content ViewController or TabBar Controller with Content ViewController.
I strongly recommend you to study iOS5 storyboard tutorials to get to know how the view controllers interacts.

IPhone sdk Login Control Segue issue

Hi I am new to Iphone Development and using iphone sdk5.
I am trying to implement an application through which I can login and show my application if login is successful, otherwise show the error alert.
problem which I am facing right now is that I have first view as View controller and I want to send the login details through clicking the login button and I want to perform the Segue through the same button if the Login is success full and show my TabBar Application. I have tried to implement basic push Segue as well as Custom segue... someway I was able to do through custom segue by checking the if(Flag)..then perform the segue... but the point is that I set the flag when i see the login is correct otherwise it should not set the Flag... now when I run the application I have to click the button twice and then the segue is performed and I get to my application TabBarController..
Please share some alternate ways also if you have better suggestions for me...
Any Ideas... please answer as soon as possible..
Thanks for time
The best method I can think of is:
You can ctrl-drag from the First view controller to the Second view (tab view controller). [You can use the view controller object at the bottom of the scene to do this.]
Create a identifier for the segue which was created, on the right hand side.
Define a IBAction for your Login button
Inside the IBAction do your FLAG checks
If the condition is TRUE then you call the
[self performSegueWithIdentifier: #"identifier_name_you_gave" sender:self];

Reset the whole view

I have a UITabBarController, each tabs governs it's own UITableViewController. I have a singleton User object in my app and I also have a logout button in which logs out the user and presents a modalViewController of the login page. When I logout I also have the User object to send a postNotification to the three UITableViewController in order to reset the view and stuff. The question is how do I reset the view so it's fresh like when someone starts with the app again, clearing previous data? What's the best way to do this? Thanks
When each tableview controller receives the notification, it can just empty the data array and reload the table.

Present login screen on app startup

In my previous question on UIView animations I mentioned that I have to simulate the modal behavior for some view. Here I'll explain why and ask about some better solution.
The first view a user should see in my app is the login screen. Upon successful authentication the program checks if the user is a parent or a child (in a family). For each of these roles the app must provide different functionality.
So I designed the app like this:
Declare outlets for the login view controller and a tab bar controller (for the main part of the interface) in my AppDelegate.
In the application:didFinishLaunchingWithOptions: method
Set the rootViewController of the main window to the login view controller.
Make AppDelegate the delegate for the login controller, so it can send notification when it's done its job.
When AppDelegate receives the message on successful login, it determines whether the user is a parent or a child, instantiates the set of view controllers that provide corresponding functionality and passes them to the tab bar controller.
At last AppDelegate switches the rootViewController of the main window to the tab bar controller.
Certainly the user can logout, then the rootViewController is switched back again to the login controller.
I would like to present and dismiss the login screen as if it is a modal view, but AppDelegate only has a bare window, thus I don't have an object to send presentModalViewController: to. This brings up a question:
First of all, is it a good design?
And if it is, how do I simulate a modal behavior correctly?
I think you're on the right track.
However, I always try to get out of the app delegate as soon as I can, leaving it only to do application-level things (like respond to notifications, go in and out of background). In this case, doing so will help you.
In the appDelegate, create a new UIViewController class, something like "startUpController".
Add it's view to the app window.
Then in your startUpController, do everything that you used to do in the app delegate (login, tab bar setup, etc.).
And now, since you're in a view controller, you can presentModalViewController to your hearts content.
Hii,
you should refer this
http://code.google.com/p/tweetero/
https://github.com/jbrien/WordPress-iPhone
Hope this helps!