Awesome Open Source
Awesome Open Source

UIAlertController+CNBlocks

Convenience methods for UIAlertController. It can add custom style (defalut and destructive) and actions sort by index of NSArray which contain items of custom style's actions.

Requirements

  • Greater iOS 8.0.

Style

AlertView

ActionSheet

Usage

  • Add UIAlertController+CNBlocks.h/m into your project.

Alert

Showing Alert Viiew in current toppest ViewController. Items contain title、message、cancel action、confirm action.

[UIAlertController cn_showAlertViewWithTitle:_title message:_message cancelTitle:_cancelTitle confirmTitle:_confirmTitle confirm:^{
        NSLog(@"I'm a adult!");
    }];

Showing alert in current toppest viewController. Items contain title、message、add multiple defalut style action、cancel action.

[UIAlertController cn_showAlertViewWithTitle:_title message:_message defalutActionTitles:_defalutActionTitles cancelTitle:_cancelTitle complete:^(NSUInteger index) {
        NSLog(@"index:%ld-- I'm %@", index, self->_defalutActionTitles[index]);
    }];

Showing alert in specified viewController. Items contain title、message、add multiple custom style (see CNAlertActionStyle) action、cancel action.

[UIAlertController cn_alertViewShowInViewController:self title:_title message:_message customActionTitles:_customStyleActionTitles cancelTitle:_cancelTitle complete:^(NSUInteger index) {
        NSLog(@"index:%ld-- %@", index, self->_customStyleActionTitles[index].allValues.firstObject);
    }];

ActionSheet

Showing action sheet in specified viewController. Items contain title、message、cancel action、confirm action.

[UIAlertController cn_actionSheetShowInViewController:self title:_title message:_message cancelTitle:_cancelTitle confirmTitle:_confirmTitle confirm:^{
        NSLog(@"I'm a adult!");
    }];

Showing action sheet in current toppest viewController. Items contain title、message、add multiple defalut style action、cancel action.

[UIAlertController cn_showActionSheetWithTitle:_title message:_message defalutActionTitles:_defalutActionTitles cancelTitle:_cancelTitle complete:^(NSUInteger index) {
        NSLog(@"index:%ld-- I'm %@", index, self->_defalutActionTitles[index]);
    }];

Showing action sheet in current toppest viewController. Items contain title、message、add multiple custom style (see CNAlertActionStyle) action、cancel action.

[UIAlertController cn_showActionSheetWithTitle:_title message:_message customActionTitles:_customStyleActionTitles cancelTitle:_cancelTitle complete:^(NSUInteger index) {
        NSLog(@"index:%ld-- %@", index, self->_customStyleActionTitles[index].allValues.firstObject);
    }];

License

  • UIAlertController+CNBlocks is available under the MIT license. See the LICENSE
Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Objective C (57,184
Actions (55,586
Alert (7,562
Uialertcontroller (66
Alertcontroller (28
Uialertview (22
Uiactionsheet (11