UIActionSheet&UIAlertView

UIActionSheet spa

.h 文件 it

@interface ViewController : UIViewController<UIActionSheetDelegate>
- (IBAction)ShowActionSheet:(id)sender; io

.m 文件 cli

- (IBAction)ShowActionSheet:(id)sender{
    UIActionSheet *actionSheet=[[UIActionSheet alloc]initWithTitle:@"Hello" delete:self cancelButtonTitle:@"取消" desturctiveButtonTitle:@"第一项" otherButtonTitles:@"第二项",@"第三项",nil];
    actionSheet.actionSheetStyle=UIActionSheetStyleAutomatic;  //灰色背景 和 Default同样
    *UIActionSheetStyleBlackTranslucent  //黑色半透明背景
    *UIActionSheetStyleBlackOpaque  //纯黑色背景
    *UIActionSheetStyleBlackDefault  //灰色背景
    [actionSheet showInView:self.view];
} 文件

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    if(buttonIndex=X){do...}
} view

UIAlertView vi

.h 文件 let

@Interface ViewController:UIViewController<UIAlertViewDelegate> interface

.m 文件 void

- (void)ShowAlertView{
    UIAlertView *alert=[UIAlertView alloc]initWithTitle:@"Title" message:@"Message" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles@"One",@"Two",nil);
    [alert Show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {     NSLog(@"buttonIndex:%d",buttonIndex); }

本站公众号
   欢迎关注本站公众号,获取更多信息