First, the case description: Click the button to pop up the box, click the second button to pop up the action table. 01, Figure 02, Figure 03
Fig. 01 FIG. 02 Fig. 03
Second, the case steps:
1, choose Simple View aplication, named cq.32. Warning box and action table, 04
2, Main.storyboard
3, CQ32ViewController.h
#import <UIKit/UIKit.h>@interface cq32viewcontroller:uiviewcontroller< uialertviewdelegate,uiactionsheetdelegate>-(ibaction) Testalertview: (ID) sender; -(Ibaction) Testactionsheet: (ID) sender; @end
4, CQ32VIEWCONTROLLER.M
-(Ibaction) Testalertview: (ID) sender{Uialertview*alertview = [[Uialertview alloc] Initwithtitle:@"Alert"Message@"Alert text goes here" Delegate: Self Cancelbuttontitle:@"No"Otherbuttontitles:@"Yes", nil]; [Alertview show];}#pragmaMark-The realization of uialertviewdelegate-(void) Alertview: (Uialertview *) Alertview Clickedbuttonatindex: (nsinteger) buttonindex{NSLog (@"Buttonindex =%i", Buttonindex);}-(Ibaction) Testactionsheet: (ID) sender{Uiactionsheet*actionsheet = [[Uiactionsheet alloc] Initwithtitle:nilDelegate: Self Cancelbuttontitle:@"Cancel"Destructivebuttontitle:@"Destructive button"Otherbuttontitles:@"Sina Micro-blog", nil]; Actionsheet.actionsheetstyle=uiactionsheetstyleautomatic; [Actionsheet ShowInView:self.view];}- (void) Actionsheet: (Uiactionsheet *) Actionsheet Clickedbuttonatindex: (nsinteger) buttonindex{NSLog (@"Buttonindex =%i", Buttonindex);}