简体   繁体   中英

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)

Is it possible without using webview and 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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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