iOS 学习笔记 九 (2015.04.02)IOS8中使用UIAlertController创建警告窗口
2015-04-02 17:15
417 查看
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];
}
#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学习笔记(九)之UIAlertView(警告视图)和UIActionSheet(操作表视图)基本概念和使用方法
- iOS学习笔记: 使用CAShapeLayer创建带有空心区域的遮罩层
- SilverLight商业应用程序开发---学习笔记(10)使用数据源窗口创建DataGrid
- IOS学习笔记(九)之UIAlertView(警告视图)和UIActionSheet(操作表视图)基本概念和使用方法
- iOS开发学习笔记:使用xcode里的单元测试,放在STAssert…里面的语句无法使用自动完成功能
- Struts2.0学习笔记--Session的创建和使用方法
- php学习笔记(7):PHP数组的创建修改使用
- [原创]W2k Driving 学习笔记(二)使用GCC创建 Windows NT 下的内核DLL
- iPhone开发学习笔记[3/50]-使用工具栏创建简单的多视图应用程序
- VC++学习笔记之创建窗口
- java-使用keytool来创建管理密钥及证书等-java学习笔记(3)
- [Linux网络编程学习笔记]管道的创建和使用
- [原创]W2k Driving 学习笔记(二)使用GCC创建 Windows NT 下的内核DLL
- 动态链接库创建与使用(学习笔记) .
- ios学习笔记(一)xcode 4.3.2下创建第一个ios项目
- Sharepoint学习笔记---SPList--使用Linq to Sharepoint间接查询External List(1.通过BCS创建External List)
- D3D学习笔记之一---创建D3D环境的窗口
- 学习笔记:web服务的创建及使用
- Smart Client学习笔记(7) 使用多线程创建高响应智能客户端应用程序
- [iOS学习笔记] 通过FMDataBase使用sqlite数据库