2011-01-28 28 views
0

我試圖讓這個控件與超文本鏈接一起工作並沒有太多的成功。我曾看過TTCalaog,並試圖補充但不起作用。TTStyledTextLabel

我有這個工作至於顯示超文本鏈接,但它不會觸發。 TDStyledTextLabel * label = [[[[TTStyledTextLabel alloc] initWithFrame:CGRectMake(5,0,315,175)] autorelease];}};

NSString * labelText = @「This should work」;

label.text = [TTStyledText textFromXHTML:labelText lineBreaks:NO URLs:YES];

[self.view addSubview:label];

我的事我很想念這裏或許與谷歌網址的位置?我在這個論壇上看到過一篇文章,它使用了custom-uri:// some/url,然後在TTURLMap和TTNavigator中設置,但是我需要在webview中從超文本中打開url,所以我需要url在我的班級運行一個方法,創建我的webview控制器等。

我試過在沒有TTNavigator的情況下使用TTURLMap工作,但完全醃製?

任何幫助gratefullt讚賞;-)

感謝

回答

1

我剛剛發現自己的解決方案,以趕在TTStyledTextLabel點擊的URL。我希望這可以幫助你的情況。

這就是我所做的。

1.創建TTNavigator

TTNavigator *navigator = [TTNavigator navigator]; 
    navigator.persistenceMode = TTNavigatorPersistenceModeNone; 
    navigator.delegate = self; 

2.創建TTNavigatorDelegate

您所指派的自我作爲導航對象的委託。因此,請記住在繼續之前在頭文件.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 
     } 
    } 

我希望這有助於!如果這有助於解決您的問題,請投我一票!

最好的問候,

相關問題