我希望我的表格列表有一个像iOS 8一样的可滑动菜单(最早是在iOS 7中引入的).
我已经找到了a Ray Wenderlich guide that is clear个关于如何做到这一点,但它是一年零四个月前写的,代码是Objective-C.
iOS 8或即将推出的iOS 9最终是否在苹果的SDK中包含了该功能?我知道他们几年前就内置了"滑动显示删除功能".我不想浪费时间实现拼凑代码来模仿iOS 8邮件功能,如果苹果的新iOS将把它装在一个包装整齐的包里交给我的话.
我希望我的表格列表有一个像iOS 8一样的可滑动菜单(最早是在iOS 7中引入的).
我已经找到了a Ray Wenderlich guide that is clear个关于如何做到这一点,但它是一年零四个月前写的,代码是Objective-C.
iOS 8或即将推出的iOS 9最终是否在苹果的SDK中包含了该功能?我知道他们几年前就内置了"滑动显示删除功能".我不想浪费时间实现拼凑代码来模仿iOS 8邮件功能,如果苹果的新iOS将把它装在一个包装整齐的包里交给我的话.
试试这个,为Swift 3(Developer Docs)更新
override func tableView(_ tableView: UITableView, editActionsForRowAt: IndexPath) -> [UITableViewRowAction]? {
let more = UITableViewRowAction(style: .normal, title: "More") { action, index in
print("more button tapped")
}
more.backgroundColor = .lightGray
let favorite = UITableViewRowAction(style: .normal, title: "Favorite") { action, index in
print("favorite button tapped")
}
favorite.backgroundColor = .orange
let share = UITableViewRowAction(style: .normal, title: "Share") { action, index in
print("share button tapped")
}
share.backgroundColor = .blue
return [share, favorite, more]
}
还要实现这一点:(你可以把它设置为有条件的,但这里的一切都是可编辑的)
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}