Reputation: 3955
I have a URL in my textview and when we click on this url it opens this url in default safari. and I want to detect this event. I also tried this
but its not working for me. can any one suggest me how i do this. Provide me a sample for this.
My application deligate is UIResponder type.
Upvotes: 2
Views: 3157
Reputation: 2141
Assuming you just need to display a static label with links, we have a fairly powerful attributed label in Nimbus that you may wish to check out:
http://docs.nimbuskit.info/group___nimbus_attributed_label.html
The label uses CoreText and NSAttributedString, so it is built on core Apple technologies. It acts in every way like a UILabel. Here's an example of implementing the NIAttributedLabel delegate:
More info: http://nimbuskit.info/
Upvotes: 0
Reputation:
the other answer works as expected.
create New File
, select Objective-C Class
MyApplication
UIApplication
paste this code in the .m
file:
- (BOOL)openURL:(NSURL *)url {
if ([self handleOpenURL:url])
return YES;
else
return [super openURL:url];
}
- (BOOL)handleOpenURL:(NSURL*)url {
NSLog(@"my url handler");
return YES;
}
next open your main.m
and change the third parameter
return UIApplicationMain(argc, argv, nil, NSStringFromClass([SampleAppDelegate class]));
to your UIApplication
-subclass name
return UIApplicationMain(argc, argv, @"MyApplication", NSStringFromClass([SampleAppDelegate class]));
Upvotes: 2