在编辑模式下的UITableView – 删除滚动上的buttonDissapears
我有一个TableView拉入自定义GroupTableView的自定义单元格。 在不处于编辑模式时,我可以滚动浏览而不会出现任何问题(所有的数据都保留在正确的单元格中)。 但是,当我进入编辑模式时,在滚动表格时,删除button消失。
这是我的tableview的代码:
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int { return groups.count } func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! { var cell: GroupTableView = tableView.dequeueReusableCellWithIdentifier(groupCellID) as GroupTableView if (cell == nil) { cell = GroupTableView(style: UITableViewCellStyle.Default, reuseIdentifier: groupCellID) } cell.groupName.text = groups[indexPath.row].groupName cell.groupOwner.text = "OwnerID: \(groups[indexPath.row].ownerID)" cell.numPosts.text = groups[indexPath.row].numPosts return cell; } func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) { if (groupTableView.editing == true) { self.performSegueWithIdentifier("segueToGroupDetail",sender:self) } else { self.performSegueWithIdentifier("segueToLinkView",sender:self) } }
这是我的代码来启用编辑模式:
override func viewDidLoad() { super.viewDidLoad() self.navigationItem.leftBarButtonItem = self.editButtonItem() } override func setEditing(editing: Bool, animated: Bool) { super.setEditing(editing,animated:animated) groupTableView.setEditing(editing,animated:animated) }
这是写得很快,但希望在概念上类似于如何在目标c中完成。
- Swift – 如何使用AlamofireImage / ImageShack节省内存?
- 我在UItextfield中input时如何更改我的UIlabel? 与旋转图标
- iOS UIButton – UIButton setUserInteractionEnabled和setEnabled之间的区别
- cocos2d 2.0-rc2:结束导演并重启
- 作为iOS开发人员实习生的12周-第七周和第八周
- 在向每个单元格添加带cornerRadius的UILabel时,UITableView会进行爬网
- Swift 3:永久存储数据
- 无法在模拟器xcode 9testing版中安装应用程序
- 在Swift中简单的服务,坚持只有前台?