UIWebView is a great control to display formatted text (using HTML language). That text might contain links that you want to intercept in Objective-C and do a specific action (push a new view for example).
You can do this by implementing UIWebViewDelegate protocol…
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
NSArray *parts = [[[request URL] absoluteString] componentsSeparatedByString:@"#language_id_"];
if ([parts count] == 2) {
TranslationViewController *vc = [[TranslationViewController alloc] initWithNibName:@"PrayerTranslationView" bundle:nil];
[self presentModalViewController:vc animated:YES];
[vc release];
return FALSE;
}
return TRUE;
}In that method you can check the requested URL and decide if you want to allow the standard flow, navigation to that URL (by returning TRUE), or do something else instead. In the example above we are showing a new view.



App submission changes
iPhone 4 reception issue: myth or fact? Design flaw or software issue?
How to build and submit a Universal App for distribution on the App Store with the iOS 4 SDK
Microsoft Pink smartphone project: KIN gets killed
Recent Comments