简体   繁体   English

Xcode如何用超链接替换文本

[英]Xcode How can I replace text with a hyperlink

I am a newbie to Xcode so please bear with me. 我是Xcode的新手,所以请多多包涵。

I have a requirement where I have a some text on my view which is loaded from API call to server. 我有一个要求,我的视图上有一些文本,这些文本是从API调用加载到服务器的。 ( in short dynamic text populated runtime). (简而言之是动态文本填充的运行时)。

Now I need to replace all @blabla and #blablabla to clickable links / buttons or anything else. 现在,我需要将所有@blabla和#blablabla替换为可点击的链接/按钮或其他任何东西。 It should be clickable and on click of it, should open another view. 它应该是可单击的,单击它应打开另一个视图。

Please suggest if I should elaborate a bit more on this. 请建议我是否应该对此进行详细说明。

Here is the use case to be more specific 这是更具体的用例

  1. View based application started 基于视图的应用程序已启动
  2. Application calls a webserver (API) and receives text paragraph. 应用程序调用Web服务器(API)并接收文本段落。
  3. It should show paragraph on screen but should replace @bla and @blabla with links and on click it should open another view ( not the webpage) 它应在屏幕上显示段落,但应使用链接替换@bla和@blabla,单击时应打开另一个视图(而不是网页)

The cheater method is to use an Open Source component. 作弊者的方法是使用开源组件。 I've not used it, but SMFancyText might do the trick. 我没有使用它,但是SMFancyText可以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM