In the action form we use a lot of buttons to implement, here we use the Uiactionsheetdelegate protocol in the Actionsheet:clickedbuttonatindex: method implementation, the syntax of the following form:
-(void) Actionsheet: (uiactionsheet*) Actionsheet Clickedbuttonatindex: (Nsinteger) Buttonindex;
where (uiactionsheet*) Actionsheet is used to specify the buttons contained in the Action form, (Nsinteger) Buttonindex is used to specify the index of the clicked button
The core code is as follows:
ViewController.h
#import <UIKit/UIKit.h> @interface viewcontroller:uiviewcontroller<uiactionsheetdelegate>{ Iboutlet Uitextview *tv; Iboutlet UILabel *l;} -(ibaction) AA: (ID) sender; @end
viewcontroller.m
-(ibaction) AA: (ID) Sender {uiactionsheet *ac = [[Uiactionsheet alloc]initwithtitle:@ "Language selection" Delegate:self Cancelbuttont itle:@ "OK" destructivebuttontitle:@ "Chinese" otherbuttontitles:@ "English", @ "Japanese", nil]; [AC ShowInView:self.view];} -(void) Actionsheet: (Uiactionsheet *) Actionsheet Clickedbuttonatindex: (nsinteger) buttonindex{NSString *t = [actionSh Buttontitleatindex:buttonindex]; if ([t isequaltostring:@ "Chinese"]) {Tv.text = @ "There was a lovely little girl, who had seen it all, but her grandmother, who liked her most, gave her what she wanted." Once, Grandma gave the little girl a velvet Little Red Riding Hood, worn on her head just right. Since then, the girl no longer want to wear any other hats, so everyone called her "Little Red Riding Hood." "; L.text = @ "Little Red Riding Hood"; }else if ([t isequaltostring:@ "English"]) {Tv.text = @ "ONCE&NBSP;THERE&NBSP;WAS&NBSP;A&NBSP;LITTLE&NBSP;GIRL,&NBSP;SHE&N bsp;always wore a red hat, so everybody called her the Little red hat.one day little red hat ' S mother said to her, " Little red hat, your grandma is ill, please go and see her, give her these cakes. remember you must Walk along the main road. " "Yes, mum i remember." SHE&NBSP;TOOK&NBSP;THE&NBSP;CAKES&NBSP;AND&NBSP;MADE&NBSP;HER&NBSP;WAY&NBSP;TO&NBSP;HER&NBSP;GRANDMA ' s. She walked and walked. suddenly she came across a big grey wolf. "; L.text = @ "litle Red Riding Hood"; }else if ([t isequaltostring:@ "Japanese"]) {Tv.text = @ "Haruko (はるこ) さんの home は Nihonbashi (にほんばし) にはありません. Asakusa (あさくさ) near (ちか) くにあります. はその (かみなりもん) west Side (にしがわ) にあります. The family (かぞく) は three people ですので. Tael (りょうしん) と ですので. "; L.text = @ "Haruko (はるこ)"; }}
iOS Development Learning # Reminder Processing # (2) Response Action form