开发者

Detect if NSString contains a URL and generate a "link" to open inside the app a Safari View

开发者 https://www.devze.com 2022-12-31 13:15 出处:网络
I have am reading a twitter feed in my iPhone application and can do it correctly, but I\'d like to evolve开发者_开发知识库 it in a way to detect if the whole NSString contains any URL or URLs and cre

I have am reading a twitter feed in my iPhone application and can do it correctly, but I'd like to evolve开发者_开发知识库 it in a way to detect if the whole NSString contains any URL or URLs and create a "link" that will open a UIWebView within the same application.

Can you guide me on how to perform this task?

-(void) setTextTwitter:(NSString *)text WithDate:(NSString*)date
{
    [text retain];
    [textTwitter release], textTwitter = nil;
    textTwitter = text;

    [date retain];
    [dateTwitter release], dateTwitter = nil;
    dateTwitter = date;

    [self setNeedsDisplay];
}


Check out Craig Hockenberry's IFTweetLabel, which can be found here.

Or you can use the label provided by Three20 library, which can be found here.

Or the simplest solution: use UIWebView with dataDetectorTypes set to UIDataDetectorTypeLink.

Cheers, Paul

0

精彩评论

暂无评论...
验证码 换一张
取 消