IPhone sdk Login Control Segue issue - iphone

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];

Related

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.

Storyboard iOS5 - How to prevent the storyboard changing when pressing the Segue button

I've created an app using the new iOS 5 Utility app template. Since the previous SDK, we now have to use storyboards for the GUI (which I do like using) but I am wondering how to prevent the "Segue" from flipping the view to the next view on the storyboard.
By default there is a button which when pressed flips to the "FlipsideViewController" and I would like to use this button as part of a login form but I need to stop the storyboard going to the Segue unless the credentials are correct. I have all my login code written but cannot prevent the page from flipping. The method I thought would do this actually prevents the user from going back by clicking the default "Done" button on the "FlipsideViewController".
Can anyone help?
You have to connect the button to an IBAction instead of a segue. In the action, check if the credentials are correct, then call performSegue: to perform it.
You will have to connect the segue directly from the view controller to the next scene instead of from the button.

Presenting view from app delegate

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];

Load the root view when app enter into background in iPhone sdk

I am developing an application which has 4 views and use navigation controller to navigate through. The first view is login interface. I just want to display login view when user press home button from second view. I have tried to use popToRootViewControllerAnimated in applicationDidEnterBackground. This does not work. Because I need to do this job only user press home button from second view (Second view contains MKMapView).
Can you please let me know what is the best option for this job? Basically I just need to check what view I am currently on.
Many Thanks
You could log a BOOL variable that the viewDidAppear function on your second controller sets to YES. And when you leave that view set it to NO. In applicationDidEnterForeground check it. If it is YES then the user left while in the second view.

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!