0
我正在使用STTweetLabel來顯示推文是我的應用程序中的表格視圖。使用STTweetlabel在瀏覽器中打開鏈接
,我必須包含指向網站如「http://www.google.com」
飼料什麼,我試圖做的是,當用戶觸摸的tweet中的鏈接,它會打開Safari和引導他們到任何鏈接是。
請告訴我發生在一分鐘時,該鏈接auttomatically當在tableview中被顯示在它(無需用戶點擊)
這是代碼我到目前爲止,用於檢測鏈接打開:
@property (nonatomic, strong) NSDictionary *attributesLink;
- (NSDictionary *)attributesForHotWord:(STTweetHotWord)hotWord {
switch (hotWord) {
case STTweetHandle:
return _attributesHandle;
break;
case STTweetHashtag:
return _attributesHashtag;
break;
case STTweetLink:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:_attributesLink]];
return _attributesLink;
break;
default:
break;
}
}
編輯:
我也有這個在我的ViewController
STTweetLabel *tweetLabel = [[STTweetLabel alloc] initWithFrame:CGRectMake(10.0, 10.0, 300.0, 180.0)];
tweetLabel.text.isAccessibilityElement = YES;
[tweetLabel setText:text];
tweetLabel.textAlignment = NSTextAlignmentLeft;
CGSize size = [tweetLabel suggestedFrameSizeToFitEntireStringConstraintedToWidth:tweetLabel.frame.size.width];
CGRect frame = tweetLabel.frame;
frame.size.height = size.height;
tweetLabel.frame = frame;
tweetLabel.textSelectable = YES;
[tweetLabel setDetectionBlock:^(STTweetHotWord hotWord, NSString *string, NSString *protocol, NSRange range) {
NSArray *hotWords = @[@"Handle", @"Hashtag", @"Link"];
//[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"Link"]];
titleLabel.text = [NSString stringWithFormat:@"%@ [%d,%d]: %@%@", hotWords[hotWord], (int)range.location, (int)range.length, string, (protocol != nil) ? [NSString stringWithFormat:@" *%@*", protocol] : @""];
}];
[cell addSubview:dateLabel];
[cell addSubview:tweetLabel];
}