iOS development from getting started to mastering--warning dialog uialertview and waiting for the prompt Uiactivityindicatorview

Source: Internet
Author: User

Warning dialog box Uialertview and wait prompt Uiactivityindicatorview:
1.UIAlertView Simple is the frame
2. is called the Chrysanthemum Turn circle


Disclaimer: Notice that @interface ViewController : UIViewController<UIAlertViewDelegate> there is a uialertviewdelegate agent in this one.

#import <UIKit/UIKit.h>@interface ViewController : UIViewController<UIAlertViewDelegate>{    //定义一个警告对话框视图对象    UIAlertView * _alertView;    //等待提示对象    //当下载,或者加载比较大的文件时,可以显示此控件,处于提示等待状态    UIActivityIndicatorView * _activityIndicator;}@property(retain,nonatomic) UIAlertView * alertView;@property(retain,nonatomic) UIActivityIndicatorView * activityIndicator;@end

Realize:

#import "ViewController.h"  @interface viewcontroller ()@end @implementation viewcontroller //Implement synchronization of attributes and member variables@synthesizeAlertview =_alertview;@synthesizeactivityindicator=_activityindicator;-(void) Viewdidload {[SuperViewdidload];additional setup after loading the view, typically from a nib.     for(intI=0;i<2; i++) {UIButton* BTN =[UIButtonButtonwithtype:uibuttontyperoundedrect]; Btn. Frame= CGRectMake ( -, -+ -*i, -, +);if(i==0) {[Btn settitle:@"warning dialog box"Forstate:uicontrolstatenormal]; }Else if(i==1) {[Btn settitle:@"Wait Indicator"Forstate:uicontrolstatenormal]; } btn. Tag=101+i; [BTN AddTarget: SelfAction@selector(pressbtn:) forcontrolevents:uicontroleventtouchupinside]; [ Self. ViewADDSUBVIEW:BTN]; }}-(void) Pressbtn: (UIButton*) btn{//Warning dialog box created    //p1: Dialog box title    //P2: Tip Information    //P3: Proxy object for handling button events    //P4: Cancels the text of the button, the default index is 0;    //P5: Other button text * * otherbuttontitles:@ "OK", nil]; Only the Cancel and OK buttons are horizontally lined    //otherbuttontitles:@ "OK", @ "OK 1", @ "OK 2", nil]; This will all be vertical, and the index is in turn a.    //p6: ...: Add another button    //nil: Indicates the end of the button add    if(BTN. Tag==101) {_alertview = [[Uialertview alloc]initwithtitle:@"Warning"message:@"Your phone is low, please save the data"Delegate Selfcancelbuttontitle:@"Cancel"otherbuttontitles:@"OK",Nil];//Display dialog box[_alertview show]; }//Create a waiting prompt, everyone calls him chrysanthemum    Else if(BTN. Tag==102){//Create a wait prompt, wide-height not changeable_activityindicator =[[uiactivityindicatorview Alloc]initwithframe:cgrectmake ( -, -, the, the)];//SET hint style: small gray, small white, white_activityindicator. Activityindicatorviewstyle=uiactivityindicatorviewstylegray;//Small Ash//_activityindicator.activityindicatorviewstyle=uiactivityindicatorviewstylewhite;//small white//        //_activityindicator.activityindicatorviewstyle=uiactivityindicatorviewstylewhitelarge;//white//Self.view.backgroundcolor=[uicolor Bluecolor];[ Self. ViewAddsubview:_activityindicator];//Start the animation and display[_activityindicator startanimating];//Stop waiting for animations and hide//[_activityindicator stopanimating];}}Call this function when you click the button in the dialog box//p1: Dialog box object itself//P2: Index of the button-(void) Alertview: (Uialertview *) Alertview Clickedbuttonatindex: (Nsinteger) buttonindex{NSLog(@"index=%ld\n", Buttonindex);}//dialog box is about to disappear, this function is called-(void) Alertview: (Uialertview *) Alertview Willdismisswithbuttonindex: (Nsinteger) buttonindex{NSLog(@"is about to disappear!" ");}when the//dialog box has disappeared, call this function-(void) Alertview: (Uialertview *) Alertview Diddismisswithbuttonindex: (Nsinteger) buttonindex{NSLog(@"has disappeared.");} - (void) Didreceivememorywarning {[SuperDidreceivememorywarning];//Dispose of any resources, can be recreated.}@end

iOS development from getting started to mastering--warning dialog uialertview and waiting for the prompt Uiactivityindicatorview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.