简体   繁体   English

具有文本的滚动视图,并且在轻按特定短语时可以执行某些操作

[英]Scrollable view with text and ability to do something when specific phrase is tapped

I am trying to implement a view which will load text from sqlite database (every sentence in a text will have unique tag in database) and will allow to execute some code while sentence is clicked (on-click executed method should then scroll clicked sentence to the center of the screen and change it's color/background color/font size to emphasize it) 我正在尝试实现一个视图,该视图将从sqlite数据库加载文本(文本中的每个句子在数据库中都将具有唯一的标记),并允许在单击句子时执行一些代码(在单击时执行的方法应将单击的句子滚动到屏幕中心并更改其颜色/背景色/字体大小以突出显示)

Is it possible without using webview and js/js-native bridge? 是否可以不使用webview和js / js-native bridge? Which approach should be taken to implement such a view? 应该采用哪种方法来实现这种观点? Any help and comments highly appreciated! 任何帮助和意见,高度赞赏!

Hmm, you could also considering using NSAttributedString together the Core Text Framework and attribute each sentence and attach some extra info about. 嗯,您还可以考虑将NSAttributedString与Core Text Framework一起使用,并为每个句子赋予属性,并附加一些其他信息。 Next you lookup the attribute below the tap position of the view. 接下来,您在视图的点击位置下方查找属性。 Once you have that you can retrieve the extra info again and do whatever you want with the tap. 一旦有了,您就可以再次检索额外的信息,并用水龙头做任何想做的事情。

After the tap you could then alter the properties of that part of the text. 点击之后,您便可以更改该文本部分的属性。 Eg different font colour etc. 例如,不同的字体颜色等。

This tutorial on the internet looked interesting: http://www.raywenderlich.com/4147/how-to-create-a-simple-magazine-app-with-core-text 互联网上的本教程看起来很有趣: http : //www.raywenderlich.com/4147/how-to-create-a-simple-magazine-app-with-core-text

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

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