swift iOS中的tableView函数

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift iOS中的tableView函数相关的知识,希望对你有一定的参考价值。

override func tableView (tableView: UITableView, 
                                    commitEditingStyle editingStyle: UITableViewCellEditingStyle,                                        forRowAtIndexPath indexPath: NSIndexPath)

func tableView: 
  A table view is the scrolling thing that's containing all the dates in the 
  example project, and is a core component in iOS.

tableView: UITableView 
  contains two pieces of information: 
  tableView 
    is the name that we can use to reference the table view inside the method
  UITableView 
    is the data type. 
    Everything that begins with "UI" is something Apple provides as part of its iOS development kit,     so UITableView is the default Apple table view.
  
commitEditingStyle editingStyle: UITableViewCellEditingStyle 
  commitEditingStyle
    is the actual action: this code will be triggered when the user tries to 
    commit the editing style of a table view. That means this code will be called 
    when the user tries to add or delete data from the table.

tableView: UITableView, 
  it meant we could reference the table view by using the "tableView" parameter, 
  but here the parameter is commitEditingStyle, which would be quite a clumsy 
  way to reference the parameter. So 
  Swift lets you give parameters external names: 
    one used when passing data in (commitEditingStyle, in this case) and 
    one to be used inside the method (editingStyle). 
  
  Finally, there's : UITableViewCellEditingStyle, 
    which means that the editingStyle parameter will be of data type UITableViewCellEditingStyle.

forRowAtIndexPath indexPath: NSIndexPath 
  Here's that sneaky parameter naming again, 
  people calling the method would write forRowAtIndexPath, 
  inside the method you would use just indexPath. 
  
  It's of data type NSIndexPath, which holds two pieces of information: 
    a table section and 
    a table row. 
  We aren't using sections here, but we are using rows – in the example project, every date 
  that is inserted is one row.

以上是关于swift iOS中的tableView函数的主要内容,如果未能解决你的问题,请参考以下文章

在 iOS Swift 中,在 Swift 4 中的 TableView 中为 CollectionView 集成不同的数组

使用核心数据swift ios获取实体的所有属性到tableview中的行中的标签

iOS swift UIImageView更改tableView单元格中的图像

了解 tableView 等函数中的 Swift 参数表示法

如何在iOS swift的tableview中使用json响应中的键和值?

使用核心数据swift ios将实体的所有属性获取到tableview中的行中的标签