JCAlertController
is same level
with UIAlertController
.
It is inherited
from UIViewController
too.
It supports managing presented controllers with FIFO
or LIFO
.
Compare | Present Queue | Custom Style | Custom View | Minimum iOS Target |
---|---|---|---|---|
JCAlertController | support | simple | simple | iOS 7 |
UIAlertController | not support | difficult | difficult | iOS 8 |
- support present queue
- support custom style
- support custom contentView
Look at the flowing code:
[self presentWithFIFO:alert1];
[self presentWithFIFO:alert2];
[self presentWithFIFO:alert3];
Result:
alert1 shows first
, after dismissed by user, alert2 shows second
, after dismissed by user, alert3 shows third
.
like this: alert1
>> alert2
>> alert3
[self presentWithLIFO:alert1];
[self presentWithLIFO:alert2];
[self presentWithLIFO:alert3];
Result:
alert3 shows first
, after dismissed by user, alert2 shows second
, after dismissed by user, alert1 shows third
.
like this alert3
>> alert2
>> alert1
Present queue is powered by JCPresentQueue. It supports cocoapods too.
.
|____.DS_Store
|____AlertView
| |____JCAlertView.h
| |____JCAlertView.m
|____ButtonItem
| |____JCAlertButtonItem.h
| |____JCAlertButtonItem.m
|____Category
| |____NSAttributedString+JCCalculateSize.h
| |____NSAttributedString+JCCalculateSize.m
| |____UIColor+JCHightlightedColor.h
| |____UIColor+JCHightlightedColor.m
| |____UIImage+JCColor2Image.h
| |____UIImage+JCColor2Image.m
| |____UIViewController+JCPresentQueue.h // present category
| |____UIViewController+JCPresentQueue.m
| |____UIWindow+JCBlur.h
| |____UIWindow+JCBlur.m
|____JCAlertController.h // import this
|____JCAlertController.m
|____Style
| |____JCAlertStyle.h
| |____JCAlertStyle.m
| |____JCAlertStyleAlertView.h
| |____JCAlertStyleAlertView.m
| |____JCAlertStyleBackground.h
| |____JCAlertStyleBackground.m
| |____JCAlertStyleButton.h
| |____JCAlertStyleButton.m
| |____JCAlertStyleButtonCancel.h
| |____JCAlertStyleButtonCancel.m
| |____JCAlertStyleButtonNormal.h
| |____JCAlertStyleButtonNormal.m
| |____JCAlertStyleButtonWarning.h
| |____JCAlertStyleButtonWarning.m
| |____JCAlertStyleContent.h
| |____JCAlertStyleContent.m
| |____JCAlertStyleSeparator.h
| |____JCAlertStyleSeparator.m
| |____JCAlertStyleTitle.h
| |____JCAlertStyleTitle.m
step 1
platform :ios, '7.0'
target 'your target' do
pod 'JCAlertController'
end
step 2
#import "JCAlertController.h"
// LIFO: alert3 >> alert2 >> alert1
for (int i = 1; i<4; i++) {
JCAlertController *alert = [JCAlertController alertWithTitle:[NSString stringWithFormat:@"alert%zi", i] message:nil];
[alert addButtonWithTitle:@"OK" type:JCButtonTypeNormal clicked:nil];
[self jc_presentViewController:alert presentCompletion:nil dismissCompletion:nil];
}
E-mail: hjaycee@163.com
Blog: http://www.jianshu.com/u/8bde69945e50