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.
- Greater iOS 8.0.
- 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);
}];
- UIAlertController+CNBlocks is available under the MIT license. See the LICENSE