iOS之UIAlertView的使用
2016-03-23 22:57
375 查看
UIAlertView:
1.普通使用:
//普通的alert
UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"title" message:@"message" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"ok", nil];
[av show];
2.UIAlertView还可以设置其样式:
如果可以输入账号与密码的样式:
//普通的alert
UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"title" message:@"message" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"ok", nil];
[av setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];//设置样式:明文与暗文
[av show];
3.判断用户点击了alert的哪个按钮的协议:
//协议:alertView
//判断用户点击了alert的那个按钮
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 0)
{
NSLog(@"you click no");
}
else
{
NSLog(@"you click yes");
}
}
4. 常用方法总结:
//根据被点击按钮的索引处理点击事件
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"clickButtonAtIndex:%d",buttonIndex);
}
//AlertView已经消失时执行的事件
-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"didDismissWithButtonIndex");
}
//ALertView即将消失时的事件
-(void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"willDismissWithButtonIndex");
}
//AlertView的取消按钮的事件
-(void)alertViewCancel:(UIAlertView *)alertView
{
NSLog(@"alertViewCancel");
}
//AlertView已经显示时的事件
-(void)didPresentAlertView:(UIAlertView *)alertView
{
NSLog(@"didPresentAlertView");
}
//AlertView即将显示时
-(void)willPresentAlertView:(UIAlertView *)alertView
{
NSLog(@"willPresentAlertView");
}
1.普通使用:
//普通的alert
UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"title" message:@"message" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"ok", nil];
[av show];
2.UIAlertView还可以设置其样式:
如果可以输入账号与密码的样式:
//普通的alert
UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"title" message:@"message" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"ok", nil];
[av setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];//设置样式:明文与暗文
[av show];
3.判断用户点击了alert的哪个按钮的协议:
//协议:alertView
//判断用户点击了alert的那个按钮
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 0)
{
NSLog(@"you click no");
}
else
{
NSLog(@"you click yes");
}
}
4. 常用方法总结:
//根据被点击按钮的索引处理点击事件
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"clickButtonAtIndex:%d",buttonIndex);
}
//AlertView已经消失时执行的事件
-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"didDismissWithButtonIndex");
}
//ALertView即将消失时的事件
-(void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"willDismissWithButtonIndex");
}
//AlertView的取消按钮的事件
-(void)alertViewCancel:(UIAlertView *)alertView
{
NSLog(@"alertViewCancel");
}
//AlertView已经显示时的事件
-(void)didPresentAlertView:(UIAlertView *)alertView
{
NSLog(@"didPresentAlertView");
}
//AlertView即将显示时
-(void)willPresentAlertView:(UIAlertView *)alertView
{
NSLog(@"willPresentAlertView");
}
相关文章推荐
- UIBezierPath精讲
- UITableViewCell的使用介绍
- iOS UITextField的基本用法
- 封装简单的equery
- 有了Auto Layout,为什么你还是害怕写UITabelView的自适应布局?
- 修改UIBarButtonItem字体大小、颜色等相关属性
- 关于在自定义的导航栏中使用UIImagePickerViewControlle
- Number Sequence (KMP算法)
- iOS UILabel 设置行高
- CF_3D_LeastCostBracketSequence
- easyui datagrid 动态生成列
- IOS开发UI篇--使用CAShapeLayer实现复杂的View的遮罩效果
- 自定义导航栏的时候使用UIImagePickerViewControlle Item无法正常显示
- ABAP SAPGUI_PROGRESS_INDICATOR 显示数据处理进度
- UVA 11039(p78)----Building designing
- UESTC 1271(dp动态规划)
- UESTC 1143
- poj1458 Common Subsequence(最长公共子序列)
- 112. Path Sum My Submissions Question
- UESTCACM 每周算法讲堂 延迟标记+bfs dfs搜索入门