why are my gestures not being reconized when i enter my app via URL Shortcut (open pdf in my app)?

42 views Asked by At

I have a gesture on a UITableView set up like so

//tableView:cellForRowAtIndexPath:
UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
[cell addGestureRecognizer:lpgr];

in my app delegate, I'm handling shortcuts like so

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
if (url == nil) {
    NSLog(@"Shortcut: None");
    return NO;
}
NSLog(@"Shortcut: %@", [url absoluteString]);

    NSURLComponents *urlC = [[NSURLComponents alloc] initWithURL:url resolvingAgainstBaseURL:NO];
    if ([urlC.scheme isEqualToString:@"file"]) { //file:///private/var/mobile/...../Documents/Inbox/file.pdf

        FSCategoriesTVC *FSCategoriesTVC = [_window.rootViewController.storyboard instantiateViewControllerWithIdentifier:@"FSCategoriesTVC"];
        FSCategoriesTVC.isUploadingFile = YES;
        FSCategoriesTVC.fileToUpload = url;
        FSCategoriesTVC.navigationItem.prompt = @"Select project to add files to";

        UINavigationController *navController = [[UINavigationController alloc] init];
        [navController setViewControllers:@[FSCategoriesTVC] animated:NO];

        if(_window.rootViewController.presentedViewController != nil) {
            [_window.rootViewController dismissViewControllerAnimated:NO completion:^{ }];
        }
        [_window.rootViewController presentViewController:navController animated:NO completion:^{}];
        return YES;
    }
return NO;
}

what I'm doing is opening .pdf files in my app and uploading them to S3 to look at later. however, when the app launches this way, my gestures aren't recognized

e: i replace the gesture with a framework called BAMContextualMenu, hoping that would solve my problem, nope. same problem, the gesture aren't recognized when launching from shortcut

1

There are 1 answers

2
Sterling Christensen On
  1. Try the view debugger to see if your view hierarchy is different when opened with a URL
  2. Try handling the URL in application:willFinishLaunchingWithOptions: instead, because application:openURL:sourceApplication:annotation: is deprecated. You can retrieve the URL from the options dictionary using the UIApplicationLaunchOptionsURLKey key. That way you'll be initializing your view hierarchy with the same code whether or not there is a URL, which in my experience can be more foolproof. You can also implement application:openURL:options:.