I'm developing a iPhone App, in which I'm changing the ViewController using presentModalViewController method upto 2/3 levels (e.g. Home-->Option-->Other-->More).
Now I want to get my app back to first screen or ViewController. If I use dismissModalViewControllerAnimated method, it just dismisses the current view controller only. But I want to clear the stack and start the Home screen again.
Thanks for any help.
Set the delegates properly for each level. So if you press Cancel or Done in More, it will call somehting like [other moreViewDidCancel] inside of which, you will call dismissModalViewController:Animated: and notify its parent view controller (delegate) that is should dismiss( so, [option otherViewDidCancel]) and so on till the top level.
Related
I am creating a project with Xcode 4.2 and using it's storyboard. In one of the views I have a button that a user will tap and it will perform some calculations. If the calculations are correct I need to display the view that they just came from. I am currently using a Navigation Controller. When the app starts it loads View 1. When I choose an option it loads View 2. If I click the 'back' button in the toolbar it loads View 1 with left animation.
In my IBAction method for the View 2 calculation I have the following snippet.
[self performSegueWithIdentifier:#"BackToView1" sender:sender];
But the problem is it loads View 1 using the left animation when I need it to load the right.
Would that be a custom segue? Am I missing something?
[Edit]
I just noticed something as well. When View 1 loads from my IBAction it appears it is initializing the AppDelegate again, whereas the 'back' button does not. I need to not initialize the AppDelegate since I am loading a data object at the start of the app. Calling init again kills my object.
You could try using the navigation controller to pop back. This will probably produce the effect you are after.
[self.navigationController popViewControllerAnimated:YES];
My application has tab bar with one of the tabs having a segmented control on navigation bar.
Based on segment clicked different view is displayed using a url.
I am calling the url in viewdidload method.I do not want to use viewwillAppear to call the url as it will be called each time the view is displayed.
I only want to call the url again whenever user closes the application and comes back.
Whats the best way to do this.Should I remove the view controller from and reload it again once the application is opened.
Please use a more descriptive title for your question next time!
There are notifications for this that you can observe in your application:
UIApplicationDidBecomeActiveNotification and UIApplicationWillEnterForegroundNotification come to mind.
I want to create an application.
The application will let people to read jokes, for example. Then people can press a button and another view show up where people can insert their own jokes.
After people finish inserting their own joke, I want them to go back the previous screen.
What would be the standard way to do so?
Put all controllers on application delegate and change the rootviewcontroller?
One possibility would be to use the presentModalViewController:animated: method of the root UIViewController to present the "joke inserter" view.
Once the joke insert was complete (or if the user cancelled the insertion) you'd simply return to the previous view as-is.
The uinavigation controller will work well. U can push people to a new controller where they enter their joke and then pop them back to the root. U can do this with or without animation. Set up the UiNavigationController in the app delegate and initialize it with your jokesviewcontroller as the root.
Here is a post I just did on this subject
Programming iOS: clarifications about Root View Controller
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!
I am writing an application(for iPhone) that uses the UINavigationController to show different view via pushViewController. I am trying to push multiple UIViewController immediately upon application startup without user interaction. When an user open up the application, they will be looking on a screen with a navigation bar on the top that already have a back button.
The problem I am experiencing is that viewWillDisappear and viewDidDisappear of a ViewController does not always get call if another ViewController is pushed on top of it immediately upon application start up without user interaction. If the ViewController being pushed on top is activate by the user with a button click, then viewWillDisappear and viewDidDisappear of the view being cover always get call.
Note. viewWillAppear and viewDidAppear of the covered view controller always get called.
In the code that is experiencing the problem, I am pushing the new view controller in viewDidAppear of the previous ViewController.
Anyone know what I might be doing wrong or if the behavior I am seeing is expected?
The problem I am experiencing is that viewWillDisappear and viewDidDisappear of a ViewController does not always get call if another ViewController is pushed on top of it immediately upon application start up without user interaction.
Sound pretty sensible to me. After all, the "covered" view never appeared on screen, so it cannot disappear. I would expect this behavior.