UIAlertView提示控件和UIActionSheet的使用

来源:互联网 发布:搜索引擎优化实战培训 编辑:程序博客网 时间:2024/06/05 10:43

一 UIAlertView:

1、UIAlertView 是系统提供的提示UI控件,出现在屏幕的中间。使用时可通过代理来触发相应的方法

UIAlertView 代理方法UIAlertViewDelegate
2、初始化  alertView

<span style="font-size:18px;">//  初始化{UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"温馨提示:"message:@"明天你好!"delegate:self cancelButtonTitle:@"取消按钮"otherButtonTitles:@"其他按钮",nil];// 让 显示 alertView[alertView show];}</span>




3、UIAlertView 的代理 UIAlertViewDelegate

- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{//点击的是哪个按钮,通过buttonIndex 来判断。一个是取消按钮,一个是其他的按钮,buttonIndex 为0或者1}

二 UIActionSheet:

1、UIActionSheet 也是系统提供的提示UI控件,它从屏幕的底部弹出来,使用时可通过代理来触发相应的方法

UIActionSheet 代理方法UIActionSheetDelegate

2、初始化  UIActionSheet

<span style="font-size:18px;">//  初始化{UIActionSheet *sheet = [[UIActionSheet alloc]initWithTitle: @"更换图片" delegate:self cancelButtonTitle:@"取消"destructiveButtonTitle:@"本地图片"otherButtonTitles:@"其他图片",nil];// 挂上代理,并把它添加到self.view 上   sheet.delegate =self;    [sheet showInView:self.view];}</span>



3、UIActionSheet 代理方法UIActionSheetDelegate

<span style="font-size:18px;">//  代理方法UIActionSheet 代理方法UIActionSheetDelegate- (void)actionSheet:(UIActionSheet*)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{点击的是哪个按钮,通过 buttonIndex 来判断。}</span>


0 0
原创粉丝点击