Block bar implementation added code to mark out

Source: Internet
Author: User

//
Tableviewcontroller.swift
2015.09TableView
//
Created by on 15/9/15.
Copyright (c) 2015 Leven. All rights reserved.
//

Import UIKit

Class tableviewcontroller:uitableviewcontroller{

var plistdata:nsdictionary!//dictionary has keys and values

var plistgroupname:nsarray!

Override Func Viewdidload () {
Super.viewdidload ()

Let Plistpath = Nsbundle.mainbundle (). Pathforresource ("Team_dictionary", OfType: "Plist")
Self.plistdata = Nsdictionary (contentsoffile:plistpath!)

var templist = Self.plistdata.allKeys as nsarray//all the key out of the attribute list file is cast to the array type.

Self.plistgroupname= Templist.sortedarrayusingselector ("compare:")//The number of nodes assigned to the order of the keys taken above
}


Override Func didreceivememorywarning () {
Super.didreceivememorywarning ()
Dispose of any resources the can be recreated.
}

MARK:-Table View Data source

Override func Numberofsectionsintableview (Tableview:uitableview), Int {

Return self.plistgroupname.count//the number of sections in the table view is the number of sectionnum, and a plistgroupname in the property list file is a group
}

Override Func TableView (Tableview:uitableview, numberofrowsinsection a section with how many rows section:int), Int {

var groupname refers to a group B group, etc. = Self.plistgroupname[section] as string//here the Sectionnum has been assigned to the above, to obtain the result a group name, B group name
var listteams = Self.plistdata[groupname] As nsarray//here is a set of groups, through a group of names to find, by the B group name to find and so on; Get a list team, a listteams is a row
Return listteams.count//the number of rows in a section, we have 4 teams here, and we get the team number.

}

Override Func TableView (Tableview:uitableview, Cellforrowatindexpath indexpath:nsindexpath), UITableViewCell {
Let Cellidentfier = "Cellidentifier"
var cell:customtableviewcell! = Tableview.dequeuereusablecellwithidentifier (cellidentfier) as? Customtableviewcell
if (cell = = nil) {
Cell = UITableViewCell (Style:UITableViewCellStyle.Default, Reuseidentifier:cellidentfier)
//    }

Let section = Indexpath.section
Let row = Indexpath.row
Let GroupName = self.plistgroupname[section] as String
var listteam = Self.plistdata[groupname] as Nsarray

Cell.customlabel.text = Listteam[row] as? string//the whole paragraph is not very understanding, I hope to explain

//
Let ImagePath = nsstring (format: "%@.png", rowdict["image"] as String)
Cell.customimage.image = UIImage (Named:imagepath)

return cell


}
}

Block bar implementation added code to mark out

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.