Uiactionsheet is not recommended for use after iOS8.3. can use
Uialertcontroller+uialertcontrollerstyleactionsheet get the same effect
Create Uiactionsheet
as = [[Uiactionsheet alloc]initwithtitle:@ " Select a hero "delegate: Self Cancelbuttontitle:@ "Cancel " destructivebuttontitle:@ " Delmar " Otherbuttontitles:@ " piano girl ", nil];
// Set style as. Actionsheetstyle = Uiactionsheetstyleblackopaque;
Implementing Protocol Methods
- (void) Actionsheet: (Uiactionsheet *) Actionsheet Clickedbuttonatindex: (nsinteger) buttonindex{Switch(buttonindex) { Case 0: NSLog (@"This is the No. 0 one ."); Break; Case 1: NSLog (@"This is the 1th one ."); Break; default: Break; }}
Using the Uialertcontroller+uialertcontrollerstyleactionsheet implementation
Uialertcontroller * AC = [Uialertcontroller alertcontrollerwithtitle:@"Choose a Hero"Message@"Nothing"Preferredstyle:uialertcontrollerstyleactionsheet]; [AC addaction:[uialertaction actionwithtitle:@"Cancel"Style:uialertactionstyledefault handler:^ (Uialertaction *_nonnull Action) {NSLog (@"Cancel"); }]]; [AC addaction:[uialertaction actionwithtitle:@"Delmar"Style:uialertactionstyledefault handler:^ (Uialertaction *_nonnull Action) {NSLog (@"Delmar"); }]]; [Self Presentviewcontroller:ac animated:yes completion:nil];
iOS starts--ui uiactionsheet