Shimen the main contribution, respect the work of the author, please do not reprint.
If the article is helpful to you, you are welcome to donate to the author, support the Shimen, donate the amount at random, ^_^
I want to donate: Click Donate
Cocos2d-x source Download: Dot I teleport
Alertview ControlsPopup dialog box:Modify the Hellohaomengzhu project code to add Alertview:
-(Ibaction) Testalert {nsstring *str = [[NSString alloc] initwithformat:@ "Hello,%@", Txtfield.text]; Uialertview *alert = [[Uialertview alloc] initwithtitle:@ "hint" message:str delegate:self cancelbuttontitle:@ "OK" Otherbuttontitles:nil]; [STR release]; [Alert show]; [Alert release]; } -(void) Alertview: (Uialertview *) Alertview Diddismisswithbuttonindex: (Nsinteger) Buttonindex {NSLog (@ "%@", @ "OK");}
actionsheet Controls
Actionsheet and Alertview are similar to the user a hint message. It is ejected from the bottom. It is commonly used to identify potentially dangerous or irrevocable operations, such as deleting a data.
In order to use actionsheet we need to implement the Uiactionsheetdelegate protocol in the H file. Among them, we often need to achieve: Actionsheet:diddismisswithbuttonindex:
The method is called when the actionsheet disappears.
Modify the Hello-.h file
@interface hellohaomengzhuviewcontroller:uiviewcontroller{ Uitextfield *txtfield; Uiactivityindicatorview * Myactivityview; Iboutlet Uiprogressview *progress; Nstimer *timer;}
Add the protocol uiactionsheetdelegate in the Hello_controller.h file:
-(Ibaction) testactionsheet {nsstring *str = [[NSString alloc] initwithformat:@ "Hello,%@", Txtfield.text]; Uiactionsheet *action = [[Uiactionsheet alloc] initwithtitle:@ "hint" delegate:self cancelbuttontitle:@ "Cancel" destructivebuttontitle:@ "Determine" Otherbuttontitles:nil]; [STR release]; [Action ShowInView:self.view]; [Action release]; } -(void) Actionsheet: (Uiactionsheet *) Actionsheet Diddismisswithbuttonindex: (Nsinteger) Buttonindex {if (ButtonIndex = = [Actionsheet Destructivebuttonindex]) {NSLog (@ "%@", @ "OK");} else if (Buttonindex = = [Actionsheet Cancelbuttonindex]) { NSLog (@ "%@", @ "Cancel");}}
wait for the control
For some time-consuming processing, it is necessary to use some waiting controls to eliminate the user's mind waiting.
Wait for the relevant control to have:
Uiactivityindicatorview
Uiprogressview
Design UI:
The realization of Uiactivityindicatorview
-(Ibaction) OnClickButton2: (ID) Sender {if ([Myactivityview isanimating]) {[Myactivityview stopanimating];} else {[ Myactivityview startanimating];}}
The realization of Uiprogressview
-(ibaction) start{progress.progress = 0.0;timer = [Nstimer scheduledtimerwithtimeinterval:1.0 target:self selector:@ Selector (update) Userinfo:nil Repeats:yes];}
Code Description:
Nstimer is an implicit way to start a thread ,
SCHEDULEDTIMERWITHTIMEINTERVAL Specifies how much time the thread sleeps to be called once, The method specified by the selector update.
-(void) update{progress.progress = progress.progress + 0.1;if (progress.progress = = 1.0) {[Timer invalidate]; Uialertview *alert = [[Uialertview alloc] initwithtitle:@ "task notification" message:@ "Yui Hatano. avi Download complete!" Delegate:self cancelbuttontitle:@ "OK" otherbuttontitles:nil];[ Alert show]; [Alert release];}}
Code Description:
The progress property of the Uiprogressview control is the 0.0~1.0 annoying range. 0.0 time at the beginning of the position, 1.0 is the progress to 100%.
Shimen the main contribution, respect the work of the author, please do not reprint.
If the article is helpful to you, you are welcome to donate to the author, support the Shimen, donate the amount at random, ^_^
I want to donate: Click Donate
Cocos2d-x source Download: Dot I teleport
Start from scratch IOS8 programming iOS development common controls