NSAttributedString可用于将本机应用程序操作与单词连接吗? [英] Can NSAttributedString be used to connect native app actions with the words?

查看:91
本文介绍了NSAttributedString可用于将本机应用程序操作与单词连接吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道NSAttributedString可用于检测超链接和设置样式等。

I understand that NSAttributedString can be used for detecting hyperlinks and setting the styling, etc.

但是,我需要字符串的某些部分才能实际链接到应用程序中的特定操作。例如,考虑文本

However, I need certain parts of the string to actually "link" to specific actions in the app. For example, consider the text

"this links should open up a native view for [photo 1] and [video 2]"

我不希望照片1和视频2链接到网络。我想要一个新的photoviewcontroller堆叠在现有的导航堆栈之上。

I do not want photo 1 and video 2 to link to the web. i want a new photoviewcontroller to stack on top of the existing navigation stack.

这可以用NSAttributed String实现吗?如果没有,有什么简单的方法可以做到这一点?如果可能的话,我不想使用单独的UI控件,因为在定位方面会非常混乱。

Can this be achieved with NSAttributed String? If not, what is an easy way to do this? I do not want to use separate UI controls if possible, cause that will be very messy in terms of positioning.

推荐答案

您可以让您的应用处理自定义URL方案。另外,您可以使用 JTextView 的子类 UITextView 创建一个带有使用自定义URL方案的超链接的属性字符串。

You could have your app handle a custom URL scheme. Separately, you would use the JTextView subclass of UITextView to create an attributed string with hyperlinks that use the custom URL scheme.

这篇关于NSAttributedString可用于将本机应用程序操作与单词连接吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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