TT样式文本标签

发布于 2024-10-14 11:23:21 字数 621 浏览 2 评论 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:标签];

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

我尝试自定义 TTURLMap 在没有 TTNavigator 的情况下工作,但完全腌制了?

任何帮助感激不尽;-)

谢谢

I'm trying to get this control to work with a hypertext link with not much success. I have looked at TTCalaog and tried to replecate but does not work.

I have this working as far as displaying the hypertext link but it does not fire.

TTStyledTextLabel* 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];

I thing I am missing the point here perhaps with the placement of the google url? I have seen a post on this forum that makes use of custom-uri://some/url that is then set up in TTURLMap and TTNavigator, but I need to open a url from the hypertext in a webview so I need the url to run a method in my class that creates my webview controller etc.

I have tried to cusomise TTURLMap to work without a TTNavigator but completely pickled?

Any help gratefullt appreciated ;-)

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

揽月 2024-10-21 11:23:21

我刚刚找到了一个解决方案来捕获 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
        }
    }

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

最好的问候,

I've just found myself a solution to catch the clicked URL on a TTStyledTextLabel. I hope this could help in your case too.

This's what I have done.

1. Create TTNavigator

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

2. Create TTNavigatorDelegate

As you assigned self as delegate of the navigator object. Therefore, please remember to add protocol in the header file .h before you continue.

In the implementation, create this method

    - (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
        }
    }

I hope this helps! Please vote for me if this helps to solve your issue!

Best Regards,

Thang

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文