I\'m developing and iPhone 3.0 application. And I\'m trying to open web links in a UITextView into a UIWebView instead of Safari. But still no luck.
The UIText
The simplest way is to override the webView:decidePolicyForNavigationAction:request:frame:decisionListener: method on UITextView like so:
@interface UITextView (Override)
@end
@class WebView, WebFrame;
@protocol WebPolicyDecisionListener;
@implementation UITextView (Override)
- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id < WebPolicyDecisionListener >)listener
{
NSLog(@"request: %@", request);
}
@end
This will affect all UITextViews in your application. If you only require this on a single view, create a subclass and override the method on that.
Note: this is technically a private API and could be removed at any time. There is no way to do this via the public API.
edit: as of iOS 7.0 a new method has been introduced on UITextViewDelegate to support this. See nihad's answer for details.