gpt4 book ai didi

ios - 无法从另一个 (iPhone) 中启动应用程序

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:22:56 25 4
gpt4 key购买 nike

我遵循了完全相同的教程 Launch an app from within another (iPhone)但代码只执行其他部分并显示警报,所以我无法打开第二个应用程序。您可以在上面的链接中看到我遵循的步骤。

假设我们有两个应用程序,分别称为 FirstApp 和 SecondApp。当我们打开 FirstApp 时,我们希望能够通过点击一个按钮来打开 SecondApp。解决方案是:

在 SecondApp 中

进入SecondApp的plist文件,需要添加一个URL Schemes,字符串为iOSDevTips(当然你也可以再写一个字符串,看你自己了)

2。在 FirstApp 中

使用以下操作创建一个按钮:

- (void)buttonPressed:(UIButton *)button
{
NSString *customURL = @"iOSDevTips://";

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:customURL]])
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:customURL]];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"URL error"
message:[NSString stringWithFormat:@"No custom URL defined for %@", customURL]
delegate:self cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
}

}

最佳答案

在info.plist中添加自定义Url

第一张图片 - 在您打开的应用中

第二张图片 - 在您打开的应用中

In Your App which you are opening

In Your App which from you are opening

如需完整说明和代码,请访问我的博客 here

关于ios - 无法从另一个 (iPhone) 中启动应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39528769/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com