[iPhone] Launch Safari from a link in a UIWebView?

I have a UIWebView with my app's built-in help documentation. I have a few links in these bundled pages that I would like to open in mobile Safari. Obviously, these links just load in my app's UIWebView. If you add target="_blank" to the link, the UIWebView does nothing when the link is clicked. I can't find any url schemes that will launch Safari that wouldn't also be handled by the web view.
So if this is even possible, how can it be done?

You'll have to forgive me, but I am a complete newbie to XCode - and I have been playing with the myGoogle example as a starting point to fumbling around the application; but I'm really not sure where your code needs to be added.
I also found another example on dougdiego.com, which extends your concept to keep relative links within WebView, but send anything beginning http/https (and therefore likely to be external) to Safari;
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
   navigationType:(UIWebViewNavigationType)navigationType; {
   NSURL *requestURL =\[ \[ request URL ] retain ];
   // Check to see what protocol/scheme the requested URL is.
   if ( ( \[ \[ requestURL scheme ] isEqualToString: @"http" ]
      || \[ \[ requestURL scheme ] isEqualToString: @"https" ] )
      && ( navigationType == UIWebViewNavigationTypeLinkClicked ) ) {
      return !\[ \[ UIApplication sharedApplication ] openURL: \[ requestURL autorelease ] ];
   // Auto release
   \[ requestURL release ];
   // If request url is something other than http or https it will open
   // in UIWebView. You could also check for the other following
   // protocols: tel, mailto and sms
   return YES;
The narrative alongside the above code said "The method shouldStartLoadWithRequest is a delegate method that is called when a link is clicked on. You can override the method and tell it to open in Safari.", which is all very well - but I suspect I need to understand what a delegate method is, and how I override it
Any help would be much appreciated.

Similar Messages

  • Launching Safari from terminal window

    Hi,
    I would like to launch Safari from the terminal window to an HTTP url. When I do that Safari launches with file://http://.
    One of the suggestions I've heard is to use open -a, as I am launching other browsers/applications, I would like to keep one consistent way of launching the browser.
    Thanks
    loganwol.

    Pietro_D wrote:
    (The application is for the iPhone, I think NSWorkspace isn't part of the SDK...)
    You left that part out. I guess you're on your own as I haven't looked at the iPhone SDK at all. Sorry.

  • How do I stop my iPhone 5s safari from syncing with my iPad Air which is for company use only

    I basically have been given an iPad Air for company use only so therefore cannot have anything from my personal iphone syncing with my ipad. Stupidly I signed in with the one Apple ID account. I've turned on private browsing and turned off my iCloud and I've also turned auto syncing off in iTunes. Will this do the trick? And if I turn it in again will my history be synced? Thanks.

    Hi,
    The answer is to delete everything off your iPad and set it up again as a new device with a new Apple ID.
    If you go to Settings>iCloud and choose Delete Account, this will get rid of your Apple ID on the iPad.
    Then you need to go to Settings>General>Reset>Erase All Content and Settings.
    Once that's done, set up the iPad as a new device, and create a new Apple ID when doing so.

  • Launching autoresponder from a link..?

    Currently, I have a form that when filled out, a confirmation page is displayed and an autoreponder is sent with the details of the form submission. However, not every person who fills out the form wants a copy of what was submitted. I have a new setup where the form is filled out and only a confirmation page is loaded, then at the bottom I have a link that if they want a copy, they click it and it launches another form that has an autoresponder attached. This is not very elegant because it also creates two cases. Someone know of a more elegant way to send an autosponder (or email the content of the form) via a link?

    Because you add a paramater to the form action what you want to do with javascript is have a tick on the form itself.
    Do you want to recieve a confirmation email? Yes No.
    Then if No you append to the action the paramater to supress the auto responder.
    Pretty easy

  • Safari doesn't open maximized from a link in email

    When I open Safari from a link in the email program I use (Eudora Pro), the webpage doesn't open maximized-fills only about half of the monitor screen. Any ideas on how to troubleshoot this problem. I did right-click on the Safari icon and changed the setting to open Safari maximized-still doesn't open it completely from a link.

    Hi Swarup,
                     You know to tell which mail format are you using, whether is Outlook or Lotus. SAP Connectors need to be installed for the same depending upon the mail type.
    Regards,
    Abhishek Raj.

  • Stopping Safari from auto-opening all old windows

    I find Safari openning all of my windows from when I last shut down incredibly aggrivating. Not only to I not want it but it takes FOREVER to get its barings and even start to load all the pages. I don't understand why Lion has all of these incredibly un-useful features turned on by default with no clear way how to turn them off.
    If any one knows how to stop this from happening I'd greatly appriciate it. I've done a search and not really found anything. Thanks!

    3 or 4 things you can do.
    (1) Turn off this "resume" feature for all applications via the checkbox near the bottom of the System Preferences, General pane.
    (2) Close all windows by hand before you quit safari.
    (3) option-quit safari.
    (4) Launch Safari from the dock using shift-click.
    charlie

  • I can't open Safari from the bar at the bottom

    Can anyone help please.  I am not able to open the Safari from the bar at the bottom, I get a message saying that Safari quit unexpectedly & it instructs me to Reopen but when I click on the button the same message appears.  I have also been unable to open PDF documents & wonder if this is related to downloading the Lion OS?
    Thanks
    Renee

    I am not able to open the Safari from the bar at the bottom
    Hi Renee ..
    That "bar" is referred to as the Dock.
    Drag the Safari icon straight up off the Dock. It will go "poof" ...
    Now try launching Safari from your Applications folder. If you have moved the Safari app from the Applications folder, you need to drag it back.
    As for PDF documents, go to   ~/Library/Internet PLug-Ins
    Move the Adobe PDF Browser plug in to the Trash.
    Try Safari.
    ~ (Tilde) character represents the Home folder.
    For Lion:   To find the Home folder in OS X Lion, open the Finder, hold the Option key, and choose Go > Library

  • HT1222 I need some help.... I Have the iPhone 4S and downloaded the new software (6.0) and everything seems great so far except when I try to open a link in safari from a different app (messages, Facebook, ext..) it glitches and won't load. Any advice?

    I need some help.... I Have the iPhone 4S and downloaded the new software (6.0) and everything seems great so far except when I try to open a link in safari from a different app (ie..messages, Facebook, ect..) it glitches and won't load. The blue loading bar will just jump back and forth and the page will not load properly if at all....

    It sounds like you may have multiple problems, but none of them are likely to be caused by malware.
    First, the internet-related issues may be related to adware or a network compromise. I tend to lean more towards the latter, based on your description of the problem. See:
    http://www.adwaremedic.com/kb/baddns.php
    http://www.adwaremedic.com/kb/hackedrouter.php
    If investigation shows that this is not a network-specific issue, then it's probably adware. See my Adware Removal Guide for help finding and removing it. Note that you mention AdBlock as if it should have prevented this, but it's important to understand that ad blockers do not protect you against adware in any way. Neither would any kind of anti-virus software, which often doesn't detect adware.
    As for the other issues, it sounds like you've got some serious corruption. I would be inclined to say it sounds like a failing drive, except it sounds like you just got it replaced. How did you get all your files back after the new drive was installed?
    (Fair disclosure: I may receive compensation from links to my sites, TheSafeMac.com and AdwareMedic.com, in the form of buttons allowing for donations. Donations are not required to use my site or software.)

  • IPad Air: Can't launch Safari or YouTube from the link in emails. Any idea?

    Can't launch Safari or YouTube from the link in emails. Any idea?

    Have you tried restarting or resetting your iPad?
    Restart: Press On/Off button until the Slide to Power Off slider appears, select Slide to Power Off and, after It shuts down, press the On/Off button until the Apple logo appears.
    Reset: Press the Home and On/Off buttons at the same time and hold them until the Apple logo appears (about 10 seconds).
    No data will be lost.

  • How do I stop iPhone Safari from dynamically resizing the visual viewport?

    Sorry I post this here, but I couldn't access the developer forums (no error given, it just keeps returning me to this page https://developer.apple.com/devforums/) I'm not even sure wether that's been moved here and it's just the redirection non working.
    I need to Stop iPhone Safari from dynamically resizing the visual viewport, or in other words, to stop it from trying to "fit" the layout into the viewport.
    Why?
    Because any recalculation javascript does on absolutely positioned elements makes the whole site super IRRESPONSIVE.
    I don't know wether the issue is the element going out the already-set layout viewport (which triggers the page resizing to fit the visual viewport) or just the calculations being made constantly, but I can stop the calculations from happening when not "touching" the screen, but I need a way to stop the page resizing.
    I tried setting the viewport width to 1040px, as my layout width, and it fixed the header's width being narrower than the body (or shifted left?), but the whole page is still resized with every motion-frame (one every 3 seconds, due to overloading the redrawing engine)
    Is there a way to prevent that?

    No, that link doesn't solve it. It just says the same is found everywhere online.
    There's probably no way to do it, as per their way they "accidentally" omitted the oposite case: the page being wider than 980. They only mention what to do if the site is narrower. Something I learned is big companies (with reputation management) could let you run in circles for years no answer rather than telling you something is not possible.
    I'm the developer (can't access the dev forums, don't know why) and I DID setup the viewport, scale and other properties but none of them stopped from re-fitting the new re-sized layout in the viewport. They just ensure the "initial" view.
    I think the feature I'm looking for must be achieved with some JavaScript function targeting Safari-proprietary variable/property… if even possible.
    I just had to make things never reaching the edge until somebody contributes something useful

  • Genio appears from nowhere whenever I launch Safari. How do I uninstall. I can't find an uninstall application.

    Genio appears from nowhere whenever I launch Safari. How do I uninstall. I can't find an uninstall application. I have manually deleted Genio from Applications, Application Support and Preferences. How do I get it out of my computer?

    See this link for removal:  http://www.thesafemac.com/art/
    When installing apps you get from places like CNET & Softronics they wrap the installer with their adware. You have to manually uncheck NOT to install. I've seen the Genieo as "Install Genieo with a checkbox" in a very small font. See example here:
    Beware of adware included in installers
    (Fair disclosure: Needhelp4Mac is my site. I may receive some form of compensation, financial or otherwise, from my recommendation or link.)
    OS X 10.9.3 added Genieo to list of incompatible software. If possible I would upgrade to Mavericks.

  • I have a movie site app banner ad that I cannot delete from my IPhone 5 Safari page.  I appears every time I open Safari.  Any suggestions.

    I have a movie site banner ad that I cannot delete from my IPhone 5 Safari page.  It appears every time I open Safari.  How can I delete it?

    You do not have a virus.  Sounds like you are just being bitten by Safari's desire to reopen all windows - and reconnect to all sites that were open in those windows - in Mac OS X 10.7.  I believe that if you hold down option (or is it shift?) while opening Safari that it will not try to reload those pages.
    Regarding malware, see my Mac Malware Guide:
    http://www.reedcorner.net/guides/macvirus
    (Note that my pages contain links to other pages that promote my services, and this should not be taken as an endorsement of my services by Apple.)

  • Help me!! safari from iphone 4 for fb worked

    i was on fb this morning on my macbook pro
    that was around 4 AM
    after i got off work, around 9:30 am, it wouldnt launch
    it keeps saying SAFARI CANNOT FIND FACEBOOK SERVER
    but everything else works: YOUTUBE, ETSY, CTV, BANKING
    safari from iphone 4 to launch facebook worked too.... my internet is working fine, but this morning i did also have a freak accident of some sort on my other app called FITBIT, its an app that works with a fitness tracker device.... it wouldnt detect device to sync data, saying check internet connection, i finally got fed up and tried deleting it, i guess it was in use? it tells me to put it back or end it first, i end it, still cannot delete, so i put it back... now the dock showed a broken app design.... so i shutdown mac and power it up, it lets me delete.... i reinstall... everything there is fine now.... but what happened to safari facebook? did i break that too?
    is it possible to delete safari? and i dunno.. like reinstall it? short of yanking the router power i dunno what else to do... help me!!!!
    *** someone please tell me: fact or fiction: DO WE NEED TO BUY VIRUS PROTECTION SOFTWARE FOR MACS? i was under the impression apple included it in their routine updates... and btw: i just updated the mac today... just before posting here... so my system is at the lastest whatever you call it.... im pretty stupid i dunno what anything on the mac is called

    For your iPhone ...
    It's not a virus and pre installed apps such as Safari cannot be deleted.
    Try resetting > iPhone, iPad, iPod touch: Turning off and on (restarting) and resetting
    If that doesn't help, tap Settings > General > Reset > Reset All Settings
    Then restart iPhone. Try Facebook.
    For your Mac.
    With Safari open, from the menu bar click Safari > Preferences then select the Privacy tab
    Click:  Remove All Website Data
    Now press Command + Option + E to empty the Safari cache.
    Try Safari.
    For a Mac running v10.7 Lion or v10.8 Mountain Lion, Safari on a Mac can only be reinstalled by using OS X: About OS X Recovery
    For a Mac running v10.6 Snow Leopard or a previous OS X, you can reinstall OS X (includes Safari) from the install disc that came with your Mac.
    If you aren't certain which OS X is installed, click the Apple menu icon top left in your screen.
    From the drop down menu click About This Mac. The version is noted there.
    Never disconnect the power cord from an electrical outlet while the Mac is on. You can force the Mac to turn off by holding down the Power button until the screen goes black.

  • Links in Mail won't launch Safari

    Can someone share how to get the embedded links in Mail to launch Safari. If Safari is open the link will open in the browser but if not, the embdded link in Mail just flashes like it's trying, but nothing happens. Obviously this used to work but some update, etc. has rendered it "broken."
    NOTE* I researched the archives before asking this question and spotted a couple other folks with the same symptoms but no one solved the problem. For the record I have Safari assigned as my default browser and Mail as the defalt mail app.
    Thanks
    Daniel

    Daniel,
    try to duplicate the problem when you make a new User account on your Mac:
    - open System Preferences, Accounts
    - click the + sign and make a new User
    - switch to the new user account (appears top right when you click on your user name)
    - start Mail and enter your email account settings
    - try sending a Mail
    If this duplicates your problem, the Mail program itself maybe corrupt and you may need to re-install.
    If this does not duplicate your problem, your problem is local.
    Not sure how you can repair this, but you might try to drag your plist file to the desktop and restart Mail:
    Open Preferences from within the Mail program and note the exact settings for your email accounts.
    Quit Mail
    Drag the following file to the desktop:
    your home directory / Library / Preferences / com.apple.mail.plist
    Restart Mail
    Re-install your mail settings
    These actions will not interfere with your mailboxes, it will simply create a new plist preference file when you re-start Mail.

  • Safari and Firefox on my desktop suddenly stopped combine ting to any website.  IPad and IPhone work fine from the same wifi. Any ideas.

    Safari and Firefox will not connect to website On desktop. IPad and IPhone work fine from the same wifi.

    Restart your router.

Maybe you are looking for

  • My Computer is a mess.

    Hi, I have a Pavilion s3713w that has been just great since I bought is a couple years ago. A week or so ago the computer started acting strange. It slowed down and things were popping up on the screen that made me think it had a virus or something.

  • How to select  multiple vendors in out going payment

    Hi, We are issuing Letter to Bank asking to issue DD against 10 Vendors. In this case Bank issuing DD and making debit as one entry. In Outgoing payment is it possible to select 10 vendors at time ( Is there any other way instead of 10 outgoing payme

  • Can't here music

    okay heres my problem, i will go into my music and start one of my songs, but i don't here anything. then i will try some of my apps and they won't work. i know this is not an earphone problem because i tried tap tap and i can here the music fine, so

  • Generating report queries

    We recently upgraded and we use GR55 to generate report queries used in our financial reports. We are not sure which report groups we need to regenerate and we want to avoid regenerating all of them because for sure not all of these are in use. The w

  • 2 fact Tables not joining to all the same dimensions

    Hi there, I have 2 Fact tables 1) Errors (count) 2) Tasks (count) both share the following dimension - customer and both have a dimension that joins only to itself 1) Errors type (joining to errors Fact) 2) Tasks type (joining to Tasks Fact) In Answe