The text will be implemented to store the data in the Plist file. It is then read in the program. Displays a section in a TableView control based on a different category.
For other implementations of TableView, please refer to the iOS Project development Practice-Learn to use TableView List control (i) "iOS project development Combat-Learn to use TableView List control (ii)" "iOS Project development Combat- Learn to use the TableView list control (iii) to understand section.
(1) Create a new property list file, which is the plist file. My name is data.plist. Enter content such as the following:
Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity /center ".
(2) The implementation of the code is as follows:
Import Uikitclass Viewcontroller:uiviewcontroller, uitableviewdatasource{var data:nsdictionary! Override Func Viewdidload () {super.viewdidload () data = Nsdictionary (ContentsOfURL:NSBundle.mainBundle (). Urlforresource ("Data", Withextension: "plist")!) } func TableView (Tableview:uitableview, Cellforrowatindexpath indexpath:nsindexpath), UITableViewCell {var cel L = tableview.dequeuereusablecellwithidentifier ("cell") as! UITableViewCell var title = Cell.viewwithtag (101) as! UILabel Title.text = (Data.allvalues[indexpath.section] as! Nsarray). Objectatindex (Indexpath.row) as? String return Cell} func TableView (Tableview:uitableview, Numberofrowsinsection section:int), Int { Return (Data.allvalues[section] as! Nsarray). Count} func Numberofsectionsintableview (Tableview:uitableview), Int {return data.count} F UNC TableView (Tableview:uitableview, Titleforheaderinsection section:int), StrinG? {return data.allkeys[section] as? String}}
(3) The final implementation results such as the following:
Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity /center ">.
GitHub home: https://github.com/chenyufeng1991.
You are welcome to inquire.
iOS project development--Learn to use TableView List control (iv) plist Read and section display