UIAlertViewBlockExtension 1.1.4

UIAlertViewBlockExtension 1.1.4

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最新发布2016年8月

Mango fever 维护。



  • 作者
  • Mangofever

UIAlertView 分类用于块表达式

特性

  • 可以使用块表达式来处理 UIAlertView 的点击。
  • 类似于 iOS 8.0 中的 UIAlertController
  • 自动使用 UIAlertController(通过 [UIAlertController class] 检查是否可用)

示例

可以添加具有块动作的按钮

UIAlertView *alertView = [UIAlertView alertViewWithTitle:@"title" message:@"message"];

[alertView addButtonWithTitle:@"OK" actionBlock:^(UIAlertView *alertView, NSInteger buttonIndex) {
  // do something for OK
}];

[alertView addCancelButtonWithTitle:@"Cancel" actionBlock:^(UIAlertView *alertView, NSInteger buttonIndex) {
  // do something for cancel
}];

[alertView show];

可以使用方便的方法

1 个按钮 - 只取消

[UIAlertView showWithTitle:@"Title" message:@"message" cancelButtonTitle:@"cancel" action:^{
        NSLog(@"cancel");
    }];

2 个按钮 - 取消 & 确定

[UIAlertView showWithTitle:@"Title" message:@"message" cancelButtonTitle:@"cancel" cancelAction:^{
        NSLog(@"cancel");
    } otherButtonTitle:@"OK" otherButtonAction:^{
        NSLog(@"ok");
    }];

要求

  • iOS 版本 4.0 或更高