0

Im looking for some help regarding to put a save like confirmation if some changes where made to a UITextField and UISegmentedControl.

Can I prevent the UINavigationController from pop the view? And then pop based on buttons in a AlertView?

I use the UITextField and UISegmented control to POST data to a webservice.

I perhaps need to use a modalView for this? but wanted first to see if someone have another idea, because I would like to keep navigation clicks down if possible.

Any suggestions for this?

Thanks,

Silversnail
  • 386
  • 1
  • 6
  • 23

2 Answers2

0

You can do what you would like without the need of a modal view.

First, you can use your text field's UITextFieldDelegate to set a flag in your controller when the field content is modified. You can reset this flag when the data is sent out.

Then you could override your UIViewContorller's viewWillDisappear to show an alert to the user in case new data have not been posted at the moment the view is going to disappear and give him the possibility of sending it to the server. This method will be called when you move to a different controller in your navigation UI, and you will not have a chance to "reject" the operation.

sergio
  • 68,819
  • 11
  • 102
  • 123
  • Ok, but if I do this it still pop the UI. I want it to wait, and based on button clicked in the AlertView pop or not pop. Is there a way for this? – Silversnail Jun 15 '11 at 19:20
0

Why not just using a UIAlertView?

EDIT: On second thought, and re-reading your question + comment, I would recommend to use a Modal View with classics OK/Cancel buttons + a UIAlertView(s) for confirmation(s). (UIAlertView "poping" on OK/Cancel is easy to do via UIAlertViewDelegate)

That's what Modal views are for, block UI until some user action has been completed. Like a form. This is how I do all my forms, and how Apple does (just look at the create mail screen for an example, or any form of iOS apps)

Adding a "Magical" action requiring user interaction on the back button of a navigation controller is bad in terms of user experience, if you hit back, you expect the view to pop, nothing else. I would then be surprised if Apple SDK even allows to cancel that event...

Vincent Guerci
  • 14,379
  • 4
  • 50
  • 56