我在一個UIViewController(不是UITableViewController)的tableview中有兩個表。現在我只想讓其中一個單元添加UITableViewCellAccessoryDisclosureIndicator讓用戶點擊查看另一個tableview。Swift:添加UITableViewCellAccessoryDisclosureIndicator並鏈接到另一個tableview
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = UITableViewCell()
if indexPath.section == 0{
cell.textLabel?.text = "\(rentTitle[indexPath.row]): \(rentArray[indexPath.row])"
}else{
cell.textLabel?.text = "\(cashflowTitle[indexPath.row]): \(cashflowArray[indexPath.row])"
}
return cell
}
第一個表格中有6行,第二個表格中有5行。我想在第二個表的第三行添加disclosureIndicator。所以問題是:1.如何在第二個表的第三行添加披露指示符? 2.如何使該行主動鏈接到另一個tableView?非常感謝!
func tableView(tableView: UITableView,accessoryButtonTappedForRowWithIndexPath indexPath: NSIndexPath){
var cell = UITableViewCell()
if indexPath.section == 1{
if indexPath.row == 2{
print(indexPath.row)
}
}
}
我試着先打印。
謝謝你的回覆。我已經解決了指標。但是,如何在「tableView:accessoryButtonTappedForRowWithIndexPath:」中添加動作? – user6702783
這是一種類似於'cellForRowAtIndex'的委託方法。以相同的方式實施輕拍按鈕。 – Harsh
我使用UIViewController而不是UITableViewController。故事板可能有點不同,UIViewController中沒有「原型單元」。我試過「var cell」並再次檢查indexPath,但不起作用。 – user6702783