give user option of returning to zxing:// on cancel

git-svn-id: https://zxing.googlecode.com/svn/trunk@2631 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
smparkes@smparkes.net 2013-04-06 23:11:46 +00:00
parent add451d5bf
commit b9cbb959c7
2 changed files with 22 additions and 1 deletions

View file

@ -16,7 +16,7 @@
@class ResultAction;
@interface ZXMainViewController : UIViewController <ZXingDelegate,UIActionSheetDelegate,ModalViewControllerDelegate> {
@interface ZXMainViewController : UIViewController <ZXingDelegate,UIActionSheetDelegate,ModalViewControllerDelegate,UIAlertViewDelegate> {
NSArray *actions;
ParsedResult *result;
}

View file

@ -143,8 +143,29 @@
[self performResultAction];
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
NSString* returnUrl = [[NSUserDefaults standardUserDefaults] stringForKey:@"returnURL"];
// NSLog(@"%@ %d", returnUrl, buttonIndex);
if (returnUrl != nil && buttonIndex != 0) {
NSURL *ourURL =
[NSURL URLWithString:[returnUrl stringByReplacingOccurrencesOfString:@"{CODE}" withString:@""]];
// NSLog(@"%@ %@", ourURL, returnUrl);
[[UIApplication sharedApplication] openURL:ourURL];
}
}
- (void)zxingControllerDidCancel:(ZXingWidgetController*)controller {
[self dismissModalViewControllerAnimated:YES];
NSString *returnUrl = [[NSUserDefaults standardUserDefaults] stringForKey:@"returnURL"];
if (returnUrl != nil) {
UIAlertView* alert = [[UIAlertView alloc]
initWithTitle:@"Return to website?"
message:nil
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Return", nil];
[alert show];
}
}
- (void)confirmAndPerformAction:(ResultAction *)action {