【发布时间】:2019-05-20 11:25:15
【问题描述】:
我有一个 UITableView 和一个使用 Swift 的自定义 UITableViewCell。当我设置 self.MyTable.editing = true 时,我在行上看到删除图标,它似乎为左侧的重新排序图标添加了空间,但重新排序图标从未显示。
我通过向单元格添加按钮确认这不是表格的宽度问题。在编辑模式下,按钮被推到我认为应该是重新排序图标的左侧。
我是否在 UITableView 或 UITableViewCell 的实现中遗漏了什么?
class MyCell : UITableViewCell
{
var previousState : UITableViewCellStateMask = UITableViewCellStateMask.allZeros
var controller:GolfBagViewController! = nil
var editButton : UIButton! = UIButton.buttonWithType(UIButtonType.Custom) as UIButton
override init(style: UITableViewCellStyle, reuseIdentifier: String!) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
// allow reordercontrol to be shown
self.showsReorderControl = true
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
class MyViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var MyTable: UITableView!
var isEditMode = false
func SetEditMode(sender:UIBarButtonItem){
// when set to true, delete icon appears on left but not reorder icon appears
isEditMode = !isEditMode
self.MyTable.editing = isEditMode
}
func tableView(tableView: UITableView!, canMoveRowAtIndexPath indexPath: NSIndexPath!) -> Bool
{
// indicate that this row can be moved
return true;
}
func tableView(tableView: UITableView!, moveRowAtIndexPath sourceIndexPath: NSIndexPath!, toIndexPath destinationIndexPath: NSIndexPath!)
{
// this never called since reorder control does not appear
var neverGetsHere = 1
}
[ OTHER IMPLMENTATION FUNCTIONS NOT SHOWN ]
}
【问题讨论】:
-
澄清:似乎为右侧的重新排序图标添加空间
标签: uitableview swift