Skip to content

Commit

Permalink
#10 use a background thread
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Feb 27, 2015
1 parent c8a9f35 commit 1024af5
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions src/ios/ActionSheet.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,27 @@ - (void) show:(CDVInvokedUrlCommand*)command {
NSString *addCancelButtonWithLabel = [options objectForKey:@"addCancelButtonWithLabel"] ?: nil;
NSString *addDestructiveButtonWithLabel = [options objectForKey:@"addDestructiveButtonWithLabel"] ?: nil;

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:title
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:addDestructiveButtonWithLabel
otherButtonTitles:nil];

for(int i = 0; i < [buttons count]; i++) {
[actionSheet addButtonWithTitle:[buttons objectAtIndex:i]];
}

if (addCancelButtonWithLabel != nil) {
[actionSheet addButtonWithTitle:addCancelButtonWithLabel];
actionSheet.cancelButtonIndex = [buttons count]+(addDestructiveButtonWithLabel == nil ? 0 : 1);
}

[actionSheet showInView:self.webView.superview];
[self.commandDelegate runInBackground:^{

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:title
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:addDestructiveButtonWithLabel
otherButtonTitles:nil];

for(int i = 0; i < [buttons count]; i++) {
[actionSheet addButtonWithTitle:[buttons objectAtIndex:i]];
}

if (addCancelButtonWithLabel != nil) {
[actionSheet addButtonWithTitle:addCancelButtonWithLabel];
actionSheet.cancelButtonIndex = [buttons count]+(addDestructiveButtonWithLabel == nil ? 0 : 1);
}

dispatch_async(dispatch_get_main_queue(), ^{
[actionSheet showInView:self.webView.superview];
});
}];
}

// delegate function of UIActionSheetDelegate
Expand Down

0 comments on commit 1024af5

Please sign in to comment.