从两个不同的笔尖Swift中追加tableview自定义单元格

时间:2015-08-26 19:43:19

标签: ios swift uitableview dictionary uibutton

我有一个ini_set('session.save_handler', 'files'); session_save_path(dirname(__FILE__).'/tmp'); session_start(); $_SESSION['Test'] = "info"; $_SESSION['Test2'] = "more info"; $orig = session_id(); session_regenerate_id(); echo "Original session is ".$orig."<br>"; echo "Regen session is ".session_id()."<br>"; ,其中包含两个自定义单元格xib文件(一个包含uitableview,第二个包含uilabel)。
我做什么 -
 1.我将tableview附加三个单元格(uibutton - 第一个xib)
 2.然后我加载第四个单元格(带uilabel - 秒xib)

从数组中获取

uibutton文本,同时也从另一个数组中获取uilabel

我的目标是 - 点击uibutton currentTitle后,它应附加1.下一个单元格数组uibutton和2. 1个单元格uilabel来自相应数组。

以下是uibutton

的代码
tableview

我知道我应该使用像func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return linesmain["start"]!.count + 1 } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { if(indexPath.row < someTagsArray.count){ var cell:TblCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as! TblCell cell.lblCarName.text = linesmain["start"]![indexPath.row] return cell } else { var celle:vwAnswers = self.tableView.dequeueReusableCellWithIdentifier("cell2") as! vwAnswers celle.Answer1.setTitle(answersmain["start"]![0], forState:UIControlState.Normal) return celle }} 这样的东西,但我不知道如何在我的情况下正确实现它。

1 个答案:

答案 0 :(得分:1)

  tableView.beginUpdates()
     var indexPath = NSIndexPath(forRow:row,inSection:0)
     var indexPath2 = NSIndexPath(forRow:row,inSection:0)
     self.tableView?.insertRowsAtIndexPaths([indexPath,indexPath2], withRowAnimation: UITableViewRowAnimation.Left)
tableView.endUpdates()

参考Apple swift示例:https://developer.apple.com/library/ios/samplecode/Lister/Listings/Swift_ListerToday_TodayViewController_swift.html