我试图让这个控件与超文本链接一起工作,但没有取得多大的成功。我看过TTCalaog,并尝试复制,但不起作用。
我已经工作到显示超文本链接,但它没有启动。
[TTStyledTextLabel alloc initWithFrame:CGRectMake(5,0,315,175)];
NSString* labelText =@“这应该有效”;
label.text = TTStyledText textFromXHTML:labelText换行符:NO:YES;
self.view加载项视图:标签;
我想我漏掉了这一点,也许是因为谷歌网址的位置?我在这个论坛上看到了一篇文章,它使用了定制-uri:// TTURLMap和TTNavigator中设置的一些/ url,但是我需要在webview中打开超文本中的url,所以我需要url在类中运行创建webview控制器等的方法。
我试过让TTURLMap在没有TTNavigator的情况下工作,但完全被腌制了?
感谢您的任何帮助;-)
谢谢
发布于 2011-06-30 03:24:28
我刚刚找到了一个在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
}
}我希望这能帮到你!如果这有助于解决你的问题,请投我一票!
诚挚的问候,
汤格
https://stackoverflow.com/questions/4827988
复制相似问题