0

我试图让这个控件与超文本链接一起工作,但没有取得多大成功。我看过 TTCalaog 并试图复制但不起作用。

就显示超文本链接而言,我有这个工作,但它不会触发。

TTStyledTextLabel* 标签 = [[[TTStyledTextLabel alloc] initWithFrame:CGRectMake(5, 0, 315, 175)] autorelease];

NSString* labelText = @"这应该可以";

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

[self.view addSubview:label];

我想我在这里错过了这一点,也许是谷歌网址的位置?我在这个论坛上看到了一篇使用 custom-uri://some/url 的帖子,然后在 TTURLMap 和 TTNavigator 中设置了该帖子,但是我需要从 webview 中的超文本打开一个 url,所以我需要该 url在我的类中运行一个方法来创建我的 webview 控制器等。

我试图让 TTURLMap 在没有 TTNavigator 的情况下工作但完全腌制?

任何帮助感激不尽;-)

谢谢

4

1 回答 1

1

我刚刚为自己找到了一个在 TTStyledTextLabel 上捕获点击的 URL 的解决方案。我希望这对你的情况也有帮助。

这就是我所做的。

1.创建TTNavigator

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

2.创建TTNavigatorDelegate

当您将 self 指定为 navigator 对象的委托时。因此,在继续之前,请记住在头文件 .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
        }
    }

我希望这有帮助!如果这有助于解决您的问题,请投票给我!

此致,

于 2011-06-30T03:24:28.843 回答