Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 仅当应用程序未处于活动状态时,在openURL函数之后不调用方法_Ios_Objective C_Nsnotificationcenter_Deep Linking_Openurl - Fatal编程技术网

Ios 仅当应用程序未处于活动状态时,在openURL函数之后不调用方法

Ios 仅当应用程序未处于活动状态时,在openURL函数之后不调用方法,ios,objective-c,nsnotificationcenter,deep-linking,openurl,Ios,Objective C,Nsnotificationcenter,Deep Linking,Openurl,访问网站上的共享url后,浏览者会被提示在我的应用程序中打开链接。如果应用程序正在运行,它就可以正常工作 但是,如果应用程序已关闭,则不会在我的ViewController上调用viewDidLoad和ViewWillAspect方法,因此我无法打开所需的ViewController 如果应用程序是从openURL函数启动的,有人知道如何让viewDidLoad函数运行吗 我目前有: AppDelegate: 视图控制器: 同样,如果应用程序之前已打开,则此功能也可以正常工作。但是,如果它已关闭

访问网站上的共享url后,浏览者会被提示在我的应用程序中打开链接。如果应用程序正在运行,它就可以正常工作

但是,如果应用程序已关闭,则不会在我的ViewController上调用viewDidLoad和ViewWillAspect方法,因此我无法打开所需的ViewController

如果应用程序是从openURL函数启动的,有人知道如何让viewDidLoad函数运行吗

我目前有:

AppDelegate:

视图控制器:


同样,如果应用程序之前已打开,则此功能也可以正常工作。但是,如果它已关闭,则此操作不起作用。谢谢大家!

当您的应用程序在没有任何其他操作的情况下从链接启动时,您的视图堆栈中没有显示的ViewController包含此代码。所以这段代码永远不会被执行。直接考虑在您的CuutabBar控制器中存在PARTIEWVIEW控制器。

只是猜测:我认为您需要在OpenURL中实例化并推送PARTIEVIEW控制器,而不是发送通知。您是否在openURL:中设置了断点,是否调用了该断点?可能是@Koen的重复项我尝试直接将其推到那里,但根据导航控制器的设置方式,它对我不起作用。openURL:方法在两种情况下都被成功调用。那么上面的代码位于哪个ViewController中?@Koen我在显示的ViewController下面有一个CustomTabBarController。显示的ViewController包含上面显示的代码。
-(BOOL) application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    if (!url) { return NO; }

    NSString *party_url = [NSString stringWithFormat:@"%@%@/", PARTYURL, url.lastPathComponent];
    [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:@"WebViewNotification" object:party_url]];
    return YES;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    appDelegate = [AppDelegate getDelegate];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(webViewNotification:) name:@"WebViewNotification" object:nil];
}

- (void)webViewNotification:(NSNotification *)notification {
    NSString *url = [notification object];
    PartyViewController *partyViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PartyViewController"];
    partyViewController.partyUrl = url;
    [self.navigationController pushViewController:partyViewController animated:YES];
}