首页 > 移动平台 > 详细

iOS UI基础-8.0 UIAlertView使用

时间:2015-09-16 19:33:05      阅读:254      评论:0      收藏:0      [点我收藏+]

弹出框的使用

1.实现代理UIAlertViewDelegate

2.弹出框

    // 弹框初始化
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"数据展示" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    
    // 设置对话框的类型
    alert.alertViewStyle = UIAlertViewStylePlainTextInput;
    
    // 取得唯一的那个文本框,显示英雄的名称
    [alert textFieldAtIndex:0].text = @"测试的拉";
    
    // 显示弹出框
    [alert show];

技术分享

// 设置对话框的类型
alert.alertViewStyle = UIAlertViewStylePlainTextInput
这里有好几种类型,比如设置没有文本框,设置登陆框等。

3.点击弹出框按钮操作

#pragma mark - alertView的代理方法
/**
 *  点击了alertView上面的按钮就会调用这个方法
 *
 *  @param buttonIndex 按钮的索引,从0开始
 */
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0) return;
    
    // 按钮的索引肯定不是0
    
    // 1.取得文本框最后的文字
    NSString *name = [alertView textFieldAtIndex:0].text;
    
    // 2.修改模型数据
    int row = alertView.tag;

   // 进行其它操作
}

 

iOS UI基础-8.0 UIAlertView使用

原文:http://www.cnblogs.com/jys509/p/4813897.html

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