Note that there are some explanatory texts on larger screens.

plurals
  1. POOpen YouTube URL in Safari instead of UIWebView
    text
    copied!<p>I'm trying to load any URL, after the initial load, in Safari. With any other webpage, this code works fine:</p> <pre><code>-(BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType { NSURL* url = [request URL]; if (UIWebViewNavigationTypeLinkClicked == navigationType) { [[UIApplication sharedApplication] openURL:url]; return NO; } return YES; } </code></pre> <p>But as soon as I head over to m.youtube.com, the code no longer does anything, and YouTube continues to load inside the UIWebView. I can't find anything about this online. Any help?</p> <p>Here is my entire .m file:</p> <pre><code>#import "SecondViewController.h" @interface SecondViewController () @end @implementation SecondViewController @synthesize topLayer = _topLayer; @synthesize layerPosition = _layerPosition; @synthesize webView = webView; #define VIEW_HIDDEN 260 - (void)viewDidLoad { [super viewDidLoad]; webView.delegate = self; [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://m.youtube.com"]]]; [webView setBackgroundColor:[UIColor clearColor]]; [webView setOpaque:NO]; webView.scrollView.bounces = NO; webView.scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite; [self performSelector:@selector(makeTick)]; self-&gt;promoteImages.contentSize = CGSizeMake(1920, 101); UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Scroll3.png"]]; [self-&gt;promoteImages addSubview:imageView]; [promoteImages setShowsHorizontalScrollIndicator:NO]; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { if (navigationType == UIWebViewNavigationTypeLinkClicked) { [[UIApplication sharedApplication] openURL:request.URL]; return NO; } return YES; } @end </code></pre> <p>And here's my .h file for the View Controller:</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import &lt;QuartzCore/QuartzCore.h&gt; #import &lt;Social/Social.h&gt; @interface SecondViewController : UIViewController &lt;UIWebViewDelegate&gt; { IBOutlet UIScrollView *promoteImages; NSTimer *time; IBOutlet UIWebView *webView; } @property (nonatomic, nonatomic) UIWebView *webView; @property (weak, nonatomic) IBOutlet UIView *topLayer; @property (nonatomic) CGFloat layerPosition; @property(nonatomic,readonly,getter=isDragging) BOOL dragging; @end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload