UITextView URL- . :
myTextView.dataDetectorTypes = UIDataDetectorTypeLink;
, URL-, . catplate github, , : http://github.com/nbuggia/Browser-View-Controller--iPhone-.
UIApplication, , openUrl. :
#import <UIKit/UIKit.h>
#import "MyAppDelegate.h"
@interface MyApplication : UIApplication
-(BOOL)openURL:(NSURL *)url;
@end
@implementation MyApplication
-(BOOL)openURL:(NSURL *)url
{
BOOL couldWeOpenUrl = NO;
NSString* scheme = [url.scheme lowercaseString];
if([scheme compare:@"http"] == NSOrderedSame
|| [scheme compare:@"https"] == NSOrderedSame)
{
couldWeOpenUrl = [(MyAppDelegate*)self.delegate openURL:url];
}
if(!couldWeOpenUrl)
{
return [super openURL:url];
}
else
{
return YES;
}
}
@end
main.m, MyApplication.h UIApplication. main.m :
int retVal = UIApplicationMain(argc, argv, nil, nil);
int retVal = UIApplicationMain(argc, argv, @"MyApplication", nil);
Finally, you need to implement the open (open) method: [url] [myAppDelegate *) so that it does what you would like with the URL. For example, it is possible to open a new view controller in it with a UIWebView and show the URL. You can do something like this:
- (BOOL)openURL:(NSURL*)url
{
BrowserViewController *bvc = [[BrowserViewController alloc] initWithUrls:url];
[self.navigationController pushViewController:bvc animated:YES];
[bvc release];
return YES;
}
Hope this works for you.
source
share