Swift:如何在dynamicUITableView中使用静态单元格

static dynamic dynamic dynamic .. .. dynamic 

我有一个dynamic内容的dynamic表格列表。 列表顶部,我需要一个静态单元格。

并试图添加一个标签在我的静态单元格来尝试function。

我的静态单元的标识符是:firstCell

dynamic小区的标识符是:cell

 override func numberOfSectionsInTableView(tableView: UITableView) -> Int { // #warning Potentially incomplete method implementation. // Return the number of sections. return 1 } override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { // #warning Incomplete method implementation. // Return the number of rows in the section. return 5 } override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! UITableViewCell // Configure the cell... cell.textLabel?.text = "test" return cell } 

此代码在我的dynamic单元格中返回5次“testing”。 当我尝试添加一个标签并使用静态单元格创build出口时,出现错误。

我已经googlesearch到了stackoverflow,但没有迅速的版本解决scheme。 怎么可能呢?

编辑改善问题:

实际上我需要两个部分,第一部分将是静态内容(我将以编程方式创build它,例如将使用uidatepicker,uipicker等),第二部分将只使用dynamic数组(这部分是okey)

你有没有尝试过这样的事情?

 override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! UITableViewCell if (indexPath.row == 1) { cell.textLabel?.text = "test" } else { // Configure the cell... } return cell } 
 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { if indexPath.row == 0 { var cell: IntroductionCell = self.tableView.dequeueReusableCellWithIdentifier("IntroCell") as! IntroductionCell cell.labelCellText.text = textArray[indexPath.row].uppercaseString return cell } else { var cell1: UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("IntroCell1") as! UITableViewCell return cell1 } } 

更改First Cell的单元标识符。

就是这个LOL

覆盖function。 打电话超级,改变它。

 class TableViewController: UITableViewController { override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { var rowCount = super.tableView(tableView, numberOfRowsInSection: section) if section == 1 { rowCount -= 1 } return rowCount } override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = super.tableView(tableView, cellForRowAtIndexPath: indexPath) return cell } }