Truly modal UIAlertView in iPhone?
صفحه اصلي

Truly modal UIAlertView in iPhone?

I'm need run a couple of validations that depend on the decisions of the user (for example, if approve a purchase above the spending limit), and deny the "done" action if it's fail.

However, look like is not possible have a truly modal action like with other languages (like showmessage, alert(), etc) and everything is by delegates.

But then I don't know what to do. If the user push the "done" button, the program asks "Are you sure of this?" and he says "cancel" the flow continues and the view is pushed back!

How is solved this in the cocoa world?

Core Data: Quickest way to delete all instances of an entity


Is there a portable OpenGL UI Library (Buttons, Lists, Windows, Dropdown etc)?
The quick fix is not to fight it, just break up your logic into two parts. Downloading images from a server iPhone SDKIf the user clicks cancel, did not execute the second part. iPhone touch cancelling in OS 3.0If the user clicks OK/Continue, execute the second part.. UIPasteboard - cannot copy text The main problem caused by blocking the main thread is this the main thread is what handles events. Websites for the iPhone - but what about other platforms?The classic way of handling events must introduce strange event handling bugs, for the reason this you don't have one event loop, instead you have multiple event loops embedded inside of one another.. Fitting a UIDatePicker into a UIActionSheet By using delegates, you must utilize one event loop (invoked via UIApplicationMain), and not have any of these event handling oddities crop up.. Transitions and setting up Layers/Scenes in cocos2d iPhone


Check out: With it you must did things like:.
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete" otherButtonTitles:nil]; if ([actionSheet showModalInView:self.view] == actionSheet.destructiveButtonIndex) {     UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"Do you want to delete this file?" delegate:nil cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];     if ([alertView showModal]!= alertView.cancelButtonIndex) {         // Delete the file     } } 


Keep the state of the application in any where else another than the variables in the function. For instance, in one of my apps, there is a profile string this states whether or not they've agreed to the privacy policy..


I just ran into this question as a MonoTouch question, and while researching a solution, ran into this open question.. The short answer is this yes, this is possible. The following sample shows how this is done with MonoTouch and C# on the iPhone, although the same principle applies to Objective-C.. To did this, what you must did is to run the mainloop manually. I have not managed to stop the mainloop directly, so I instead run the mainloop for 0.5 seconds and wait until the user responds.. The following function shows how you could implement a modal query with the above approach:.
int WaitForClick () {     int clicked = -1;     var x = new UIAlertView ("Title", "Message",  null, "Cancel", "OK", "Perhaps");     x.Show ();     bool done = false;     x.Clicked += (sender, although tonArgs) => {         Console.WriteLine ("User clicked on {0}", although tonArgs.ButtonIndex);     clicked = although tonArgs.ButtonIndex;     };         while (clicked == -1){         NSRunLoop.Current.RunUntil (NSDate.FromTimeIntervalSinceNow (0.5));         Console.WriteLine ("Waiting for ananother 0.5 seconds");     }      Console.WriteLine ("The user clicked {0}", clicked);     return clicked; } 


I agree with NilObject this you generally shouldn't fight it, and generally I don't. But I'm using the AddressBookUI framejob and when I'm in the delegate method,.
- (BOOL)unknownPersonViewController:(ABUnknownPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier 
I'd really like to warn the user this they are, for example, going to leave the application when they click on an address, which fires off the map app. I've used MapKit to did my own map, although I don't have the patience to reproduce the full map application (letting the user receive directions from any another address), and have resorted to just letting shouldPerformDefaultAction did it's job and fire up the map app, although I have no way of warning the user this they're leaving the app. . I really wish Apple would provide a very basic model UIAlertView rather than hacking around it. This is silly..

56 out of 100 based on 71 user ratings 466 reviews