首页 > 其他 > 详细

弹框alertView

时间:2015-09-15 19:55:43      阅读:317      评论:0      收藏:0      [点我收藏+]


// 创建一个弹框
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@“标题” message:@“显示的具体内容” delegate:self cancelButtonTitle:@“取消” otherButtonTitle:@“确定”,nil];

// 设置alert的显示类型(这个为message为nil时,输入message内容)
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
// 设置文本框输入的内容
NSString *text;
[alert textFiledAtIndex:0].text = text;
// 展示alert弹框
[alert show];

#pragma mark - UIAlertView代理方法
// 点击alertView上面的按钮就会调用这个方法
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 0)
{
// 一般为取消
return;
}
if(buttonIndex == 1)
{
// 1.取得文本框里的内容
NSString *name = [alertView textFieldAtIndex:0].text;
}
}
// 小技巧
alert.tag 可以用来传一个值,不需要定义全局变量;

弹框alertView

原文:http://www.cnblogs.com/shen5214444887/p/4811071.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!