gpt4 book ai didi

ios - iOS应用程序可以在不打开页面的情况下切换到Safari吗?

转载 作者:行者123 更新时间:2023-12-01 19:26:48 25 4
gpt4 key购买 nike

我知道我的应用可以通过执行以下操作在Safari中打开特定的URL:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.example.com/"]];

但是,有什么方法可以在不打开URL的情况下将我的应用切换到Safari吗?

我想切换到Safari,但是让它继续显示用户上次查看它时打开的页面。

最佳答案

不幸的是没有,除非您能弄清楚如何在非越狱环境中通过捆绑包ID启动应用程序。

否则,如果您处于越狱环境中,则可以使用以下内容通过其捆绑包ID启动应用程序:

用法:
[self launch:(@"com.apple.mobilesafari")];
码:

#pragma mark - Launch Application

-(void)launch:(NSString *)bundle {
Class SBApplicationController = objc_getClass("SBApplicationController");
id appController = [SBApplicationController sharedInstance];
NSArray *apps = [appController applicationsWithBundleIdentifier: bundle];
if ([apps count] > 0) {
//Wait .5 seconds.. then launch.
[self performSelector:@selector(launchTheApp:) withObject:[apps objectAtIndex:0] afterDelay: 0.5];
} else {
id app = [appController applicationWithDisplayIdentifier: bundle];
if (app) {
//Wait .5 seconds.. then launch.
[self performSelector:@selector(launchTheApp:) withObject:app afterDelay: 0.5];
}
}
}
-(void)launchTheApp:(id)app {
Class SBUIController = objc_getClass("SBUIController");
id uiController = [SBUIController sharedInstance];
if([uiController respondsToSelector:@selector(animateLaunchApplication:)]) {
[uiController animateLaunchApplication:app animateDefaultImage:YES];
} else {
[uiController activateApplicationAnimated:app];
}
}

注意:

以这种方式启动应用程序基本上与在SpringBoard中点击Safari图标相同。这只会启动到应用程序中,恢复以前处于 Activity 状态的任何Web session 。

关于ios - iOS应用程序可以在不打开页面的情况下切换到Safari吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6821227/

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