@@ -25,29 +25,9 @@ -(void)defineActionWithContexts:(NSMutableArray *)contexts {
2525 ]
2626 withResponder: ^BOOL (LPActionContext *context) {
2727 @try {
28- if (NSClassFromString (@" UIAlertController" )) {
29- UIAlertController *alert = [UIAlertController alertControllerWithTitle: NSLocalizedString([context stringNamed: LPMT_ARG_TITLE], nil ) message: NSLocalizedString([context stringNamed: LPMT_ARG_MESSAGE], nil ) preferredStyle: UIAlertControllerStyleAlert];
30- UIAlertAction *cancel = [UIAlertAction actionWithTitle: NSLocalizedString([context stringNamed: LPMT_ARG_CANCEL_TEXT], nil ) style: UIAlertActionStyleCancel handler: ^(UIAlertAction *action) {
31- [self alertDismissedWithButtonIndex: 0 ];
32- }];
33- [alert addAction: cancel];
34- UIAlertAction *accept = [UIAlertAction actionWithTitle: NSLocalizedString([context stringNamed: LPMT_ARG_ACCEPT_TEXT], nil ) style: UIAlertActionStyleDefault handler: ^(UIAlertAction *action) {
35- [self alertDismissedWithButtonIndex: 1 ];
36- }];
37- [alert addAction: accept];
3828
3929 [[self visibleViewController ]
40- presentViewController: alert animated: YES completion: nil ];
41- } else
42- {
43- UIAlertView *alert = [[UIAlertView alloc ]
44- initWithTitle: NSLocalizedString([context stringNamed: LPMT_ARG_TITLE], nil )
45- message: NSLocalizedString([context stringNamed: LPMT_ARG_MESSAGE], nil )
46- delegate: self
47- cancelButtonTitle: NSLocalizedString([context stringNamed: LPMT_ARG_CANCEL_TEXT], nil )
48- otherButtonTitles: NSLocalizedString([context stringNamed: LPMT_ARG_ACCEPT_TEXT], nil ),nil ];
49- [alert show ];
50- }
30+ presentViewController: [self viewControllerWithContext: context] animated: YES completion: nil ];
5131 [self .contexts addObject: context];
5232 return YES ;
5333 }
@@ -59,4 +39,16 @@ -(void)defineActionWithContexts:(NSMutableArray *)contexts {
5939
6040}
6141
42+ -(UIViewController *)viewControllerWithContext : (LPActionContext *)context {
43+ UIAlertController *alert = [UIAlertController alertControllerWithTitle: NSLocalizedString([context stringNamed: LPMT_ARG_TITLE], nil ) message: NSLocalizedString([context stringNamed: LPMT_ARG_MESSAGE], nil ) preferredStyle: UIAlertControllerStyleAlert];
44+ UIAlertAction *cancel = [UIAlertAction actionWithTitle: NSLocalizedString([context stringNamed: LPMT_ARG_CANCEL_TEXT], nil ) style: UIAlertActionStyleCancel handler: ^(UIAlertAction *action) {
45+ [self alertDismissedWithButtonIndex: 0 ];
46+ }];
47+ [alert addAction: cancel];
48+ UIAlertAction *accept = [UIAlertAction actionWithTitle: NSLocalizedString([context stringNamed: LPMT_ARG_ACCEPT_TEXT], nil ) style: UIAlertActionStyleDefault handler: ^(UIAlertAction *action) {
49+ [self alertDismissedWithButtonIndex: 1 ];
50+ }];
51+ [alert addAction: accept];
52+ return alert;
53+ }
6254@end
0 commit comments