data in text field disapearing - ios5

I have a view controller that pushes to another page on the same class. All data entered into the text fields on the new page vanishes as soon as I move away form it. Im assuming im missing a step here somewhere?
Do I have to connected something in page to to my original view controller?
Otherwise im going to have one long page at this rate.
xcode 4.3

I think I understand what you are saying. You have a screen that calls another screen. You call the new screen and enter data on that new screen and then navigate back to the original screen. Then you call the second screen again and the data is now missing.
Each time you call a screen you create a new UIViewController (or a subclass of that class) object. It only knows what you tell it when you create it and afterward. When you navigate back to the original screen the new screen's view controller is destroyed and all data in it unless you store the data back in the "model" (MVC) or original screen. So if you need to have the new screen show the data that was entered into it a previous time you will need to store that information in the "model" of your application or the screen that calls it. Then when you call the new screen "push" the stored data back into it.
If you are unfamiliar with the "Model" in Apple's Model-View-Controller pattern here is a good reference. Apple MVC
Hope this helps

Related

Iphone knowing when going back in navigational view control

I'm using a navigation based view controller on my iPhone app that uses an RSS feed on-load of a nib to bring back results, then another xml call when you select one. Is there an action when you go back on the second view controller to the first, the reason I ask is that it's reloading the first results again (going off to the server) as it's in the viewdidappear. How do I tell it not to re-load the results?
Tom
Move the code to the ViewDidLoad it is only called when the view gets loaded.

How do I access the view that is one level up from my current view in a navigation-based iOS app?

I'm diving into iOS development and am getting familiar with navigation view controllers. I'm trying to build a simple app with a table view that allows me to add objects to it. So far, I have a table view with an add "+" button in the nav bar that allows me to load my CreateObjectView and display it modally so the user can define the new object, but when they click the save button, I don't know how to send that object data back to the parent view that created the CreateObjectView that contains the object data.
When I create the child view (CreateObjectView), I could pass into it a pointer to the current view before I push it onto the nav stack, but this just feels dirty and circular.
I was reading about protocols and delegates and I could use that approach as well, but it also feels circular.
This question seems like it would be a common design issue to any tableview-based or nav-based app, how should I probably access the view that is one level up from my current view in a nav-based iOS app?
Thanks so much in advance for all your help!
It feels circular at first, but it is the right way. Before the UINavigationController pushes the new view controller you should set the delegate to the current view controller - assuming that's the object you wish to communicate with. Of course you could set it somewhere else instead, such as to a central Core Data handler. Then when you need to communicate call the delegate with the method you have defined. I've done several navigation apps like this after seeing Apple's cookbook example, and it really works well.

UINavigationController reloading UITableView

In my application I am parsing XML to create a UITableView. When a user selects a row it changes the file that it is parsing and reloads the UITableView.
I want to create a back button so that the user can go back the the previous XML page they were viewing.
In short how can I tell the navigation controller to create a back arrow for this page when all i am doing is reloading my UITableView?
I'd strongly suggest building another controller (i.e. UITableViewController) and push that instead of just reloading the table. This makes the button automagically, and (major plus here), it animates the whole digging down / stepping back in a way that the user is expecting it.
As a side note, I didn't manage to get a back-style button once I tried it, just a plain normal button (make a new button and set it at the navigation bar).
What you're describing is a navigation. Rather than reloading the table's data, simply push a new view controller onto the navigation stack every time a row is tapped. This is a fundamental pattern in iPhone development. Here is Apple sample code for a multi-level drill down table view.

Switching images from an array in an iphone app

I was helped here a while ago about loading images from an array, but would like to know the exact details please.
Where does the code go if my app will be as simple as images that load from an array depending on whether the user chose the next or previous button? Does it go in the View Controller class?
What do I need if I literally just need one view which displays a full screen image and the image gets changed depending on the user choice, like I mentioned above?
Thanks in advance
Regards
The view controller is responsible for controlling the view (receiving events from it, doing something then passing back data to it).
That said you can store your array in the view controller or in some other model class. Either way the view controller will be responsible for taking an image from this array and giving it to the view when it receives user input.
You just need to place a UIImageView in your view controller's view. Then assuming you're using IB you create an IBOutlet property in your controller to have a handle on this image view.
Then you need to get events from your user (either a button, or some other touch) and assign it to an IBAction that your controller can handle. When you handle the action you can remove the old image and assign a new image from your array to your UIImageView.
That's about as detailed as I can go given your current question. If you need more information please give more detail.

iphone - how to mentain the state of UIWebView?

i am having a UIWebView showing and HTML page that has some checkboxes, radio buttons. My Application has tabbar controller that switches b/w two controllers. How i can maintain the current state of UIWebView. ( e.g. i have selected a checkbox and i change the tab and go to other ViewController and again come back to UIWebView. the WebView resets itself and goes to the start... i want to maintain the state of UIWebView ( all the checkboxes clicked) .. how i will do that ??
any idea ??
thanks in advance
It sounds like you're loading your web view in viewDidAppear:, or some other method that gets called each time you switch to the tab. If you load your web view in viewDidLoad:, it will only get loaded once, and will retain its state when you switch tabs.
EDIT: When I wrote this answer back in 2009, I apparently didn't understand the view controller life cycle as well as I thought I did. Corey Floyd was right. The viewDidLoad: method can also get called multiple times, because UIViewController will unload its view in low memory situations if the view isn't being displayed. When the user switches back to the view, viewDidLoad gets called again to reconstruct the view.
How embarrassing.
I have an idea that might help:
to get the status from your app to the webpage, give the variables' values as request parameters with the called URL and let the webpage handle them and view the form elements accordingly.
to get the status from the webpage back to your app, let the webpage be refreshed each time any of its element is updated, and with the new URL give the new values of the changed elements. Back to your app, you can implement the UIWebViewDelegate and inside the method WebViewDidFinishLoad (or WebViewDidStartLoad as you prefer) use the webView.request.URL to parse the GET parameters and update your app accordingly.
hope this will help.