[英]TTStyledTextLabel
我試圖使此控件與超文本鏈接一起使用,但效果不佳。 我查看了TTCalaog並嘗試進行補充,但不起作用。
就顯示超文本鏈接而言,我可以進行此工作,但不會觸發。
TTStyledTextLabel *標簽= [[[[TTStyledTextLabel分配] initWithFrame:CGRectMake(5,0,315,175)]自動釋放];
NSString * labelText = @“這應該工作”;
label.text = [TTStyledText textFromXHTML:labelText lineBreaks:NO URLs:YES];
[self.view addSubview:label];
我想我在這里可能與Google URL的位置有關嗎? 我在該論壇上看到過一篇使用custom-uri:// some / url的帖子,該帖子隨后在TTURLMap和TTNavigator中設置,但是我需要在Webview中從超文本打開一個url,因此我需要使用在我的類中運行創建我的Webview控制器等的方法。
我試圖自定義TTURLMap,使其在沒有TTNavigator的情況下工作,但完全被腌制了?
任何幫助表示感謝;-)
謝謝
我剛剛找到一種解決方案,可以在TTStyledTextLabel上捕獲單擊的URL。 希望這對您也有幫助。
這就是我所做的。
1.創建TTNavigator
TTNavigator *navigator = [TTNavigator navigator];
navigator.persistenceMode = TTNavigatorPersistenceModeNone;
navigator.delegate = self;
2.創建TTNavigatorDelegate
當您將self分配為導航器對象的委托時。 因此,請記住在繼續之前在頭文件.h中添加協議。
在實現中,創建此方法
- (BOOL) navigator:(TTBaseNavigator *)navigator shouldOpenURL:(NSURL *)URL {
// Now you can catch the clicked URL, and can do whatever with it
// For Example: In my case, I take the query of the URL
// If no query is available, let the app open the URL in Safari
// If there's query, get its value and process within the app
NSString *query = URL.query;
if (query == nil) {
return YES;
} else {
// process the query
}
}
我希望這有幫助! 如果這有助於解決您的問題,請投票給我!
最好的祝福,
唐
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.