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
application:willFinishLaunchingWithOptions:
instead, becauseapplication:openURL:sourceApplication:annotation:
is deprecated. You can retrieve the URL from the options dictionary using theUIApplicationLaunchOptionsURLKey
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 implementapplication:openURL:options:
.