【问题标题】:why are my gestures not being reconized when i enter my app via URL Shortcut (open pdf in my app)?当我通过 URL 快捷方式(在我的应用程序中打开 pdf)进入我的应用程序时,为什么我的手势无法被识别?
【发布时间】:2016-10-17 01:09:09
【问题描述】:

我在这样设置的 UITableView 上有一个手势

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

在我的应用委托中,我正在处理这样的快捷方式

- (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;
}

我正在做的是在我的应用程序中打开 .pdf 文件并将它们上传到 S3 以供稍后查看。但是,当应用程序以这种方式启动时,我的手势无法识别

e:我用一个名为 BAMContextualMenu 的框架替换了手势,希望这能解决我的问题,不。同样的问题,从快捷方式启动时无法识别手势

【问题讨论】:

    标签: ios document-types


    【解决方案1】:
    1. 尝试使用视图调试器查看使用 URL 打开时视图层次结构是否不同
    2. 尝试处理application:willFinishLaunchingWithOptions: 中的URL,因为application:openURL:sourceApplication:annotation: 已被弃用。您可以使用 UIApplicationLaunchOptionsURLKey 键从选项字典中检索 URL。这样,无论是否存在 URL,您都将使用相同的代码初始化视图层次结构,根据我的经验,这可能更加万无一失。你也可以实现application:openURL:options:

    【讨论】:

    • 我没有看到任何明显的危险信号。我添加了第二条建议。
    • 我现在看到您的第二个建议,我不知道 application:openURL:sourceApplication:annotation: 已被弃用,因为我依赖 xcode 对我大喊大叫。我试试这个
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-19
    • 2015-06-08
    • 2016-05-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多