GKBlocks 0.0.2

GKBlocks 0.0.2

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最后发布2014年12月

Georg Kitz维护。



GKBlocks 0.0.2

为UIActionSheet和UIAlertView添加功能,支持使用block而非delegate来检查哪个按钮被点击

安装

pod 'GKBlocks'

或者您可以使用subspecs来安装

pod 'GKBlocks/UIActionSheet'
pod 'GKBlocks/UIAlertView'

用法

UIActionSheet和UIAlertView都扩展了2个初始化方法,这些方法接受一个block作为参数。对于UIActionSheet

GKActionSheetBlock block = ^(UIActionSheet *sheet, NSInteger buttonIndex) {
        NSLog(@"CancelButton Pressed = %d", sheet.cancelButtonIndex == buttonIndex);
    };

    UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Test" block:block cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"OK", nil];
    [sheet showInView:self.view];

对于UIAlertView

GKAlertViewBlock block = ^(UIAlertView *alertView, NSInteger buttonIndex) {
        NSLog(@"CancelButton Pressed = %d", alertView.cancelButtonIndex == buttonIndex);
    };

    [[[UIAlertView alloc] initWithTitle:@"Test" message:@"This is a test" block:block cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil] show];

作者

Georg Kitz, @gekitz