[UITableViewCell]小结

UITableVIewCell有预定样式的也可以自定义样式。

使用       init(style styleUITableViewCellStyle,reuseIdentifier reuseIdentifierString?)

来初始化预定义的样式

reuseidentifier的描述

A string used to identify the cell object if it is to be reused for drawing multiple rows of a table view. Pass nilif the cell object is not to be reused. You should use the same reuse identifier for all cells of the same form.

用来标记将被重新使用来显示table view的多个行的cell的字符串。如果cell对象将不会在使用,输入nil。你应该给同一个表格中的所有cell应用同样的reuse identifier。

 

方法描述中都是tells the delegate 一般我们都把ViewController设为delegate,而且会有一个自定义的类与之相关联,所以意思是说当某个时间发生的时候,某个方法就会通知我们与ViewController相绑定的类,来处理。

比如下面是tableView(tableView:UITableView,willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath)的quick help

这个Description的意思应该是table view 将要发生事件 它就会将这个事件通知给delegate 让它来处理 

也就是当一个cell将要被显示的时候调用下面这个函是

用下面这个函数来设置每个cell

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

  //required

      let cell = tableView.dequeueReusableCellWithIdentifier("hello", forIndexPath: indexPath) as UITableViewCell

  //这个函数可以通过reusedIdentifier取得cell然后对这个cell进行设置 最后返回一个cell

  //  

  return cell

 }

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {

  //没有说明required 但应该也是吧?

  //设置section 数目

}

 

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

  //required

  //设置section 里面的row 数目

 

 
posted @ 2015-02-10 07:26  baaingSheep  阅读(173)  评论(0编辑  收藏  举报