【发布时间】:2015-09-16 14:01:23
【问题描述】:
每当点击单元格上的按钮时,我都会尝试将 UITableViewCell 添加到另一个 UITableView 部分。但是,我对如何在单元格已加载到表格视图后更改单元格的部分位置的过程感到非常困惑。目前我有两个部分,并在第一部分中添加了 5 个自定义 UITableViewCells。
关于如何将单元格移动到点击的第二部分的任何想法?
这是我的视图控制器类中的单元格和部分方法:
var tableData = ["One","Two","Three","Four","Five"]
// Content within each cell and reusablity on scroll
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var tableCell : Task = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! Task
tableCell.selectionStyle = .None
tableView.separatorStyle = UITableViewCellSeparatorStyle.None
var titleString = "Section \(indexPath.section) Row \(indexPath.row)"
tableCell.title.text = titleString
println(indexPath.row)
return tableCell
}
// Number of sections in table
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 2
}
// Section titles
func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
if section == 0 {
return "First Section"
} else {
return "Second Section"
}
}
// Number of rows in each section
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if section == 0 {
return tableData.count
} else if section == 1 {
return 0
} else {
return 0
}
}
【问题讨论】:
标签: ios iphone swift uitableview cocoa-touch