我目前正在为iOS 7和iOS 8开发应用程序,并使用Swift进行Xcode 6 build 7编码。在一个视图控制器中,我有一个带有自定义单元格的表视图,问题是,当我将tableview属性编辑设置为“ true”时,什么也没有发生,我看不到删除按钮,但是如果我使用默认单元格而不是我的作品。
我已经用了所有必要的方法
func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
return true
}
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if (editingStyle == UITableViewCellEditingStyle.Delete) {
// handle delete (by removing the data from your array and updating the tableview)
}
}
func tableView(tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle {
return .Delete
}
但是什么也没有发生,有人遇到过同样的问题吗?
谢谢!!
好了,解决了,毕竟所有的解决方案一直在我面前,问题是我正在执行单元格的layoutSubviews方法,但是我完全忘记了调用super.layoutSubviews,当我这样做时,一切正常完美的。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句