1、IOS8中使用UIAlertController创建警告窗口

#pragma mark - 只能在IOS8中使用的,警告窗口
- (void)showOkayCancelAlert
{
    NSString *title = NSLocalizedString(@"修改组名", nil);
    NSString *message = NSLocalizedString(@"请输入新的组名", nil);
    NSString *cancelButtonTitle = NSLocalizedString(@"取消", nil);
    NSString *otherButtonTitle = NSLocalizedString(@"确定", nil);
    
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField)
     {
         textField.backgroundColor = [UIColor lightTextColor];       // 可以在这里对textfield进行定制,例如改变背景色
     }];
    
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelButtonTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
        NSLog(@"%s------%d-----点击取消按钮", __FUNCTION__, __LINE__);
    }];
    [alertController addAction:cancelAction];
    
    UIAlertAction *otherAction = [UIAlertAction actionWithTitle:otherButtonTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        UITextField *textField = alertController.textFields[0];                                                                 // 获取输入框中的新的组名
        if ( textField.text.length == 0 )
        {
            [[[UIAlertView alloc] initWithTitle:@"提示" message:@"您的新群组名不合理" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil] show];
            return;
        }
        NSLog(@"%s------%d-----点击确定按钮-----textField.text = %@", __FUNCTION__, __LINE__, textField.text);
        [[SingleClient sharedInstanceClient] ClientAlterGroupInfor:(int)self.curGroup.g_02_gid gname:textField.text];           // 向服务器发送修改组名的请求
    }];
    [alertController addAction:otherAction];
    
    [self presentViewController:alertController animated:YES completion:nil];
}

iOS 学习笔记 九 (2015.04.02)IOS8中使用UIAlertController创建警告窗口的更多相关文章

  1. iOS学习笔记(7)——解析json中的中文

    NSURL *url = [NSURL URLWithString:@"http://nycode.sinaapp.com/d.php"]; NSError *error = ni ...

  2. iOS学习笔记20-地图(二)MapKit框架

    一.地图开发介绍 从iOS6.0开始地图数据不再由谷歌驱动,而是改用自家地图,当然在国内它的数据是由高德地图提供的. 在iOS中进行地图开发主要有三种方式: 利用MapKit框架进行地图开发,利用这种 ...

  3. IOS学习笔记25—HTTP操作之ASIHTTPRequest

    IOS学习笔记25—HTTP操作之ASIHTTPRequest 分类: iOS2012-08-12 10:04 7734人阅读 评论(3) 收藏 举报 iosios5网络wrapper框架新浪微博 A ...

  4. iOS学习笔记-精华整理

    iOS学习笔记总结整理 一.内存管理情况 1- autorelease,当用户的代码在持续运行时,自动释放池是不会被销毁的,这段时间内用户可以安全地使用自动释放的对象.当用户的代码运行告一段 落,开始 ...

  5. iOS学习笔记总结整理

    来源:http://mobile.51cto.com/iphone-386851_all.htm 学习IOS开发这对于一个初学者来说,是一件非常挠头的事情.其实学习IOS开发无外乎平时的积累与总结.下 ...

  6. iOS学习笔记-自定义过渡动画

    代码地址如下:http://www.demodashi.com/demo/11678.html 这篇笔记翻译自raywenderlick网站的过渡动画的一篇文章,原文用的swift,由于考虑到swif ...

  7. iOS学习笔记22-推送通知

    一.推送通知 推送通知就是向用户推送一条信息来通知用户某件事件,可以在应用退到后台后,或者关闭后,能够通过推送一条消息通知用户某件事情,比如版本更新等等. 推送通知的常用应用场景: 一些任务管理APP ...

  8. Caffe学习笔记2--Ubuntu 14.04 64bit 安装Caffe(GPU版本)

    0.检查配置 1. VMWare上运行的Ubuntu,并不能支持真实的GPU(除了特定版本的VMWare和特定的GPU,要求条件严格,所以我在VMWare上搭建好了Caffe环境后,又重新在Windo ...

  9. iOS学习笔记——AutoLayout的约束

    iOS学习笔记——AutoLayout约束 之前在开发iOS app时一直以为苹果的布局是绝对布局,在IB中拖拉控件运行或者直接使用代码去调整控件都会发上一些不尽人意的结果,后来发现iOS在引入了Au ...

随机推荐

  1. http://blinkfox.com/shi-yong-spring-aoplai-tong-ji-fang-fa-de-zhi-xing-shi-jian/

    http://blinkfox.com/shi-yong-spring-aoplai-tong-ji-fang-fa-de-zhi-xing-shi-jian/ spring-aop.xml @Com ...

  2. spring mvc 静态资源 404问题

    spring mvc 静态资源 404问题 在web.xml配置servlet-mapping的时候,如果url-pattern设置为"/" (如下),很多人都会遇到导入js,cs ...

  3. JQuery:JQuery添加元素

    JQuery:添加元素通过 jQuery,可以很容易地添加新元素/内容.添加新的HTML内容.我们将学习用于添加新内容的四个jQuery方法: append() - 在被选元素的结尾插入内容 prep ...

  4. 解决: Fail to create empty document

    做 Programming Windows with MFC 2nd 的例子 MyWord 的时候. 发现启动的时候总是报错: Fail to create empty document. 搜索了一下 ...

  5. iPhone尺寸规范

    转载于:http://www.uigreat.com/page/guifan

  6. IDEA 常见文件类型的图标介绍

    官网地址:http://www.jetbrains.com/idea/webhelp/symbols.html        对于各个图标,上图的 Description 写得非常详细,但是有几个还是 ...

  7. java collections读书笔记(9)collection框架总览(2)

    框架算法: 1)collection接口 add()  Adds an element to the collection.addAll()  Adds a collection of element ...

  8. Lintcode: Sort Letters by Case

    Given a string which contains only letters. Sort it by lower case first and upper case second. Note ...

  9. Topcoder SRM 598 div2

    e,不知道为啥进不去了,这个B题贪心,从最小和最大的匹配如果超过了就只去最大的! 然后就没了- -! 这场比赛时不知为啥,string出问题了,可能是编译器挂了!0蛋- -!

  10. sdutoj 2154 Shopping

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2154 Shopping Time Limit: ...