Open safari in same tab from iPhone application

2019-06-11 16:36发布

问题:

I want to open a url link in safari from iPhone Application, but I need to open the url link in the same tab, not in New Tab as safari did.

I use the following code to open the URL:

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

But this code opens a new tab in safari each time it's invoked, is there any way to open the url link in same tab is safari?

回答1:

Short answer : No.

Long answer : Unfortunately you won't have any ability to tweak how Safari will open a new page, and here's the reason is simple. If an app opens an URL in safari, and imagine the user would like to keep it (makes sense since he didn't close it) then opening a new url on the tab will be more likely to be user unfriendly from Apple.

The only way you will have the same tab opened on Safari is that if the 8 (max number) tabs are opened, then you url will indeed open on the 8th tab on safari even if it is already opened.



回答2:

No, because that would remove the iOS devices owners last link. They could lose their link.

The only way you will have the same tab opened on Safari is that if the 8 (max number) tabs are opened, then you url will indeed open on the 8th tab on safari even if it is already opened.


There are free web browser tutorials out there, if you want more control, why not just create your own browser. Creating a mobile-browser application tutorials:

  • 2 part tutorial with web view here and here.
  • internet browser with a search bar video @youtube.com/.....