UIWebView Default no connection Page - iphone

Sorry for asking this silly question.
How can we load default safari page when not connected to the internet, like the page below, in our application?
Thanks in advance
Chahal

First check for an active Internet Connection here, then load local html file into the uiwebview here.

Did you mean : open a default page in the Safari application when taping on some button inside your application?
If yes, then here is the code :
[[UIApplication sharedApplication] openURL:[YOUR_URL_HERE]]

Related

how to open the app store when clicking button

enter image description hereI want to open the app store when I click a certain button but, I have looked everywhere, and the code I have tried takes me to a safari link or doesn't do anything at all. can anyone help me? what i want it to achieve is that i hit the button and it opens up the app store with my specified app
UPDATE: i tried the method below and it opened oped up safari saying it could open the page
Zenprogrammer79 if your using the iOS simulator the link won't work because there is no App Store on the simulator but it should work on a real iOS device
zenProgrammer79 if you have a link to another app in the App Store, you can put this code in the section of where your button gets pressed (the IBAction) (objective-c)
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"link to the application link looks like https://itunes.apple.com/au/app/sugar-calculator/id1000071935?mt=8"]];
if you are using swift i believe this will work
UIApplication.sharedApplication().openURL(NSURL(string: "https://itunes.apple.com/au/app/sugar-calculator/id1000071935?mt=8")!)
if this doesn't work then your link to the app is probably wrong.

How to place a web browser inside an iphone application?

such that when the user open the application the website referenced will be loaded in the web browser
I know the code the will open a URL with in an application
[NSURL URLWithString:#"http://www.apple.com"]];
But this is not what I need I need the application to display the web browser within its form.
If you are only to show one page I suggest you should use ModalViewController to present the page inside your app and put a UIWebView in it.
If you are to render the web page as an application than you should use UIWebView
If you want to present some pages but also want to make use of navigation functions of the safari inside your app you can use DLWebView framework which suppors ModalView with navigation function.
Here you can watch the video how it works: http://dlinsin.github.com/2011/04/24/DLWebView.html
You need UIWebView class : UIWebView Class Reference
Also you can try to search for a ready webview with all needful buttons.
Have you looked into UIWebView?
If you need browser functionality within your own app, you will need to create your own, i.e. it's not possible to embed the Safari browser within a view in your own app.

how to naviagate html url to other window

Special thanks in advance for sending me answer........
I m the beginner in iphone development. I was calling html page in the UISegment Controller.The url in that page html page is open in the same page. In html page i wrote the following code
www.google.com
But it open that url in UISegment Control of WebView on same page. I want that url open in new page of safari browser in iphone.
You can assign a delegate to your web view.
In the delegate's class, implement -webView:shouldStartLoadWithRequest:navigationType:. Then use UIApplication's -openURL: to close the app and open the page in MobileSafari.
google in a new window

How can I make iPhone hotspot login UIWebView open a link in Safari?

We have a wifi hotspot that displays a terms of service page before people are allowed to start using it.
After acceptance, a new page with a few links is displayed. I'd like to have those links open in Safari instead of in UIWebView.
I know there's a way to program UIWebView to open links in Safari, but that's not an option as this is the default UIWebView for logging into wifi hotspots and not a custom app.
Is there another way to have the links open in Safari and not in UIWebView? I've tried javascript and I've tried setting the target to _blank.
EDIT: After reading some responses, it seems like the only way to do this is to set the UIWebView delegate. I don't think this is an option because I'm not the one launching the UIWebView.
When the iPhone connects to the network (at least with version 3.0), it checks to see if it's being redirected to a login page. If it is, it does what you're saying with authentication and such inside of a UIWebView. Have you checked to see what it's reporting as the browser in use? If it isn't Mobile Safari, then you could do something server-side the first time someone connects using Mobile Safari.
If it does report as Mobile Safari when it's checking redirection, then another alternative is to figure out what site it tries to go to - maybe apple.com? Then, on the server side, the first time a different URL is loaded, redirect to your links. This will only work when the user opens Mobile Safari, however.
Other than that, I think what you're asking to do is outside of the scope of the current iPhone OS. I'd recommend filing a ‘feature request’ with Apple at bugreport.apple.com.
The only way I know how to do this is to set up a UIWebView delegate and supply something like the following:
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
if (navigationType == UIWebViewNavigationTypeLinkClicked &&
[request.URL isFileURL] == false)
{
[[UIApplication sharedApplication] openURL:request.URL];
return NO;
}
return YES;
}
The code above will cause Safari to open a link clicked on by the user. I know you said you had little control over this UIWebView -- perhaps you have more than you think by setting the delegate?
Use the openURL method of UIApplication:
NSURL *url = [[NSURL alloc] initWithString:#"http://example.com"];
[[UIApplication sharedApplication] openURL:url];
[url release];
An Apple example of this is available as part of the LaunchMe sample.

Launch Safari from iPhone App

I know that i can use the following code to launch my own url, but i want the user to continue their workflow after using my bookmarklet so therefore don't want to open a new tab and have them re-load the url i put into the url variable?
NSURL url* = [NSURL URLWithString:#"http://google.com"];
[[UIApplication sharedApplication] openUrl:""];
Can this be done?
There is no way to open Safari without actually quitting your app and opening Safari. Or to somehow automatically return the user to your app from Safari once the URL you opened loads.
Or am I misunderstanding the question?
Actually, you can delegate a URL handler to your app. A smart example is shown here:
http://www.mobileorchard.com/lite-to-paid-iphone-application-data-migrations-with-custom-url-handlers/
The scenario is:
- register URL handler
- open Safari as normal
- get Safari to use your custom URL handler that should open your app (eg: myapp://)
Have a look at the way Flickr iPhone app does the authentication.
Can you use 'about:blank' as the url? That should just open Safari with a blank page. I assume this would be similar to tapping the 'number' button in the bottom right then selecting 'new page'.