iphone - Using UIAlertView in a manner similar to Windows' MessageBox()? -


I am new on iPhone and I want to be able to use ULertView in a manner similar to Windows messagebox () or MessageDlg () in Delphi .

For example, I have a way to ask the user for confirmation on something, and proceed on the basis of their reaction.

Example (pseudocode):

  - (zero) doSomething {[doStep1]; [DoStep2]; Var myValue = [getDefaultValue]; If (myValue = Zero) {If there is no value in the [promptUser (@ "setting. Use default value?")] // UIALertview here? {MyValue = @ "defaultValue"; } And return; // bug 'out of regular' reasons we have no value} [DoStep3 withValue: myValue]; }  

Or, put it in another way - there is a way to control the argument as a rule in order to ask a question to the user. The flow of that routine?

I do not know that is MessageDlg () You can sub-class UIAlertView and control the dialog response, depending on which button is pressed, for example: UIAlertView subclass header:

  // // ARREAilityAlertView Http: // #import & lt; UIKit / UIKit.h & gt; @ Interface ARRababilityAlert view: UIAlertView & lt; UIAlertViewDelegate & gt; {} @end  

UIAlertView set the subclass implementation:

  // // ARReachabilityAlertView.m // #import " AEEBILITYVOLOHHHHHP "@EpplimentationArrayabilityElectricalView - (ID) InitVithframe: (CGRCTAT) frame {if (self = [super intwthframe: frame]) {[self settitle: @" Ever "]; [Self setMessage: @ "This app will not run without a network connection. Do you want to leave?"]; [Self Adbooten Vitalical: @ "Skip"]; [Self-coupling Vitalical: @ "Continue"]; [Self setalatet: Self]; } Healthy return; } - (zero) Warning view: (UIAlertView *) AlertViews clicked Button atindex: (NSITAZ) buttonindex {if (button index == 0) exit (0); // quit the application when pressed "quit"; Otherwise, do not do anything} - (Zero) Draw Draw: (CGRact) Rect [[Super Dracret: Rectit]; } - (zero) Delok [[Super Delooc]]; } @end  

Note Vigilance View: Clicked buttonautindex: Representative method uses this to determine the terms you use, Which is in the income of the application. You can send a NSNotification from here or call a method in the application representative, whatever you want

in my example, if there is no network connection This UIAlertView is immediate, and if the user clicks "Skip" in the warning view, the application stops. Otherwise, if the user clicks on "Continue" then it's running as usual.

Note that for the implementation of the subclass, the drawRect: method is required. I'm not sure whether this is a bug or not, because I expect drawRect: The method will be called in a super-class; I have filed a bug report with Apple on this, but I have not heard anything. If you want to see what the effect will be - it's interesting.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -