iOS swift:带有指向另一个视图的链接的 textView [英] iOS swift: textView with links to another view

查看:77
本文介绍了iOS swift:带有指向另一个视图的链接的 textView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用类似这样的测试来制作 TextView:

I'm trying to make a TextView with some test like this one:

Cras et enim ipsum.Nullam rhoncus euismod nisi 在 convallis.Etiam accumsan libero odio, egetmalesuada ligula bibendumvenenatis.

Cras et enim ipsum. Nullam rhoncus euismod nisi at convallis. Etiam accumsan libero odio, eget malesuada ligula bibendum venenatis.

链接将您带到另一个 ViewController 的位置...我想我应该使用属性文本来完成此操作,但我真的不知道如何...

where the links bring you to an other ViewController... I think I should use attributed text to accomplish this, but I really can't figure how...

另一种解决方案是使用由标签包围的按钮,但它并不优雅...

The other solution would be to use buttons surrounded by labels, but it is not elegant...

有帮助吗?

推荐答案

使用UITextView委托方法

textView(_:shouldInteractWith:in:interaction:)

您可以在此方法中检查 URL,您需要将深层链接排序到另一个视图控制器.此外,对于这种情况,此方法返回 false.

You can check for URL in this method where you need to sort of deeplink to another viewcontroller. Also, return false from this method for such cases.

如果 URLS 也可以从应用程序外部打开,您可能需要查看 iOS 中可用的 Deeplink 解决方案以进行更好的管理,并为您的用户提供 deepklink 功能.

If the URLS can also be opened from outside the app, you may want to look at the Deeplink solutions available in iOS for better management and will give your users a deepklink functionality as well.

这篇关于iOS swift:带有指向另一个视图的链接的 textView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆