不使用 openURL:url 打开 Mobile Safari

Pla*_*sma 5 xcode objective-c ios

我想打开 Mobile Safari 应用程序“无需”更改其当前显示的页面。

我可以使用 .. 轻松切换到 Safari

NSString *ourPath = @"http://www.google.co.uk";
NSURL *ourURL = [NSURL URLWithString:ourPath];
if ([ourApplication canOpenURL:ourURL]) {
    [ourApplication openURL:ourURL];
}
Run Code Online (Sandbox Code Playgroud)

但我想要做的只是切换到 safari,而不是离开它当前所在的页面。就像我使用任务切换器切换时一样,它只是弹出 Safari 并将其留在原来的页面上。

我试过给它发送一个 @"http:" 的 url,但这不起作用,它将页面更改为 "http:localhost/"

有没有办法只打开它?

等离子体

Pla*_*sma 3

我使用本页上的答案解决了这个问题..

iOS 如何使用私有 API 中的 UIApplication launchApplicationWithIdentifier?

虽然我不必将 .app 文件移至 /Applications

添加权利就足够了,然后简单地使用...调用它

[[UIApplication sharedApplication] launchApplicationWithIdentifier:@"com.apple.mobilesafari" suspended:NO];
Run Code Online (Sandbox Code Playgroud)

等离子体