我正试图让这个控件与超文本链接一起工作并没有太大的成功。我看过TTCalaog并尝试重新编写,但没有用。
我有这方面的工作,只要显示超文本链接,但它不会触发。
TTStyledTextLabel * label = [[[TTStyledTextLabel alloc] initWithFrame:CGRectMake(5,0,315,175)] autorelease];
NSString * labelText = @“这应该有用”;
label.text = [TTStyledText textFromXHTML:labelText lineBreaks:NO URL:YES];
[self.view addSubview:label];
我觉得我在这里忽略了谷歌网址的位置?我在这个论坛上看过一篇帖子,它使用了custom-uri:// some / url然后在TTURLMap和TTNavigator中设置,但我需要在webview中打开超文本的URL,所以我需要url来在我的类中运行一个创建我的webview控制器等的方法。
我试图将TTURLMap定制为在没有TTNavigator的情况下工作但完全腌制?
任何帮助感激不尽;;)
由于
答案 0 :(得分:1)
我刚刚找到了一个解决方案来捕获TTStyledTextLabel上点击的网址。我希望这对你的情况也有帮助。
这就是我所做的。
<强> 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
}
}
我希望这有帮助!如果这有助于解决您的问题,请投票给我!
最诚挚的问候,
升