File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111
1212@interface A2DynamicUIActionSheetDelegate : A2DynamicDelegate <UIActionSheetDelegate>
1313
14+ @property (nonatomic , assign ) BOOL didHandleButtonClick;
15+
1416@end
1517
1618@implementation A2DynamicUIActionSheetDelegate
@@ -22,7 +24,18 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger
2224 [realDelegate actionSheet: actionSheet clickedButtonAtIndex: buttonIndex];
2325
2426 void (^block)(void ) = self.handlers [@(buttonIndex)];
25- if (block) block ();
27+
28+ // Note: On iPad with iOS 8 GM seed, `actionSheet:clickedButtonAtIndex:` always gets called twice if you tap any button other than Cancel;
29+ // In other words, assume you have two buttons: OK and Cancel; if you tap OK, this method will be called once for the OK button and once
30+ // for the Cancel button. This could result in some really obscure bugs, so adding `didHandleButtonClick` property maintains iOS 7 compatibility.
31+ if (block && self.didHandleButtonClick == NO ) {
32+ self.didHandleButtonClick = YES ;
33+
34+ // Presenting view controllers from within action sheet delegate does not work on iPad running iOS 8 GM seed, without delay
35+ dispatch_async (dispatch_get_main_queue (), ^{
36+ block ();
37+ });
38+ }
2639}
2740
2841- (void )willPresentActionSheet : (UIActionSheet *)actionSheet
You can’t perform that action at this time.
0 commit comments