[ Showing UIAlertView (With Option) on back to previous view in iPhone App ]
I want to Show UIAlertView asking "Save" or "Don't save" on Back Click to previous view in navigation based iPhone Application.
Should I write it on, ViewWillDisappear of current View ? Is that proper ? Or any other way ?
Answer 1
First of blindly showing the UIAlertView
for saving. I suggest have a BOOL
flag in your code by default FALSE
which means data not saved. If the user saved his data then make this flag TRUE
. So when the view is about to popViewController
then check this flag. If FALSE
only then show the alertView
.
If I am not wrong, generally when you are about to pop
a viewController, you link it to some button right? in that IBAction
method put this check.