簡體   English   中英

當我通過URL快捷方式(在我的應用程序中打開pdf)進入我的應用程序時,為什么我的手勢沒有被重新調整?

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

我在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的框架替換了手勢,希望可以解決我的問題,不。 同樣的問題,從快捷方式啟動時無法識別手勢

  1. 嘗試使用視圖調試器查看使用URL打開時視圖層次是否不同
  2. 嘗試處理application:willFinishLaunchingWithOptions:的URL,因為不建議使用application:openURL:sourceApplication:annotation: 您可以使用UIApplicationLaunchOptionsURLKey鍵從選項字典中檢索URL。 這樣,無論是否存在URL,您都將使用相同的代碼初始化視圖層次結構,以我的經驗,這可能更加簡單。 您還可以實現application:openURL:options:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM