Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MythicFrost

macrumors 68040
Original poster
Mar 11, 2009
3,944
40
Australia
Hey, I've got a UIWebView in IB that's hooked up to an outlet in my code called web and it's delegate is set to First Owner, I have this code:
Code:
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
	NSLog(@"1");
	if (navigationType == UIWebViewNavigationTypeLinkClicked) {
		NSURL *URL = [request URL];
		if ([[URL scheme] isEqualToString:@"http"]){
			[navigationBar setText:[URL absoluteString]];
		}
		return NO;
	}
	return YES;
}
After I put in google.com in my address bar and click go I see the text in the console:
Code:
Unknown scheme, doing nothing: google.com
I know why, because http:// isn't in front of it, but that's the point of the code above.

I have added <UIWebViewDelegate> to my header file:
Code:
@interface MyController : UIViewController <UIWebViewDelegate>

Any idea's why that code isn't working?

EDIT: I think I had the wrong idea of this code, it will only run if the URL passed is valid, so I'm adding the HTTP:// etc... before I send the URL I want it to load.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.