How to Link to a Website or Safari within my iOS app - iphone

I am using Xcode to develop an iOS app and I need to know how to link a website to a button to open with in the app. I want o have a drop down bar that has buttons to return to a separate screen and a button to save the link to another place. Is there a way to open a website or a link to safari with my app?

You can open a website directly by using a UIWebView object in your app.
You can get Safari to open a web site by invoking something like [[UIApplication sharedApplication] openURL:myURL].

Related

UIWebView opens non-related site

I opened a website by using UIWebview, but some times when I clicked on a button or a link, it automatically calls a non-related website. E.g. when I click on a Facebook link, it goes directly to the App Store and asks for Facebook installation process (even if Facebook app is installed). After that I can't go back in my app. So I have to exit and re-open my app.
Why is it moving to the App Store even if Facebook app is already installed?
Is there any possibility to add a back option to the App Store?
Code:
webviews.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;
[webviews loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"URL of the web site"]]];
webviews.scalesPageToFit =YES;
You can use UIWebview delegate to control what the webview can or can't open (check ....shouldStartLoadWithRequest:...)
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebViewDelegate_Protocol/Reference/Reference.html

Open safari in same tab from iPhone application

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?
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.
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/.....

Open and close url in safari using objective-c program

I have to open a URL in safari... and after doing some work on safari I have to close the safari...
my code is as below.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:strPageUrl]];
Actually I have to share video on myspace.. if user has shared the video then I have to close safari and need to activate my application again.
I want to do something similar facebook SDK login with safari..
Please help me how to open this
custom url schemes work only one way... Like if you opened safari from your application then you can't return back to your application unless the second application is also yours and you have implemented another custom url to return back to your application. Since safari was made by apple so it does not have info regarding your application.
I am not exactly sure what you are trying to achieve but you can try out UIWebView for requirement if it helps.

admob click action type that launch safari and go to the web url

I have 2 admob ad on an ipad app.
One is 320*250
another one is 468*60
When I click the 2 two ads
I found the first one will go to the web url and launch safari,
the second one will push up a window and display the web url.
Is it possible to change the second ad banner action to go to the web url and launch safari also?
I am not sure if I need to change the client codes or do something on admob server side setting.
Welcome any comment
Unfortunately I don't think this is something that you can control. It looks like it's a part of the AdMob SDK where the ad creative determines what type of view to put you into when a click happens.
I have used to launch a web view safari using this code please try it. Its working fine in my Application.
NSURL *url = [NSURL URLWithString:#"http://www.stackoverflow.com"];
if (![[UIApplication sharedApplication] openURL:url])
NSLog(#"%#%#",#"Failed to open url:",[url description]);
Thanks.

Add safari bookmark from iPhone app

I'd like to have my application be able to add bookmarks to safari programmatically, is this possible?
Not really possible : there's no API for that (and you can understand it from user perspective....).
An answer here confirms it :
Add bookmark to Safari on iPhone when an application is installed?
You can't add a bookmark in Safari itself, but you can add an icon on the user's Home screen that bookmarks an arbitrary URL:
User Experience Coding How-To's for Safari on iPhone