Swift 3: UITableViewRowAction Style() "Missing Parameter" 错误信息
Swift 3: UITableViewRowActionStyle() "Missing Parameter" Error Msg
当我滑动 UITableView 单元格时,调用以下代码:
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
//Problem code
let delBut = UITableViewRowAction(style: UITableViewRowActionStyle(), title: delete_InLocal) { action, index in
//Setup
现在我已经开始迁移到 Swift 3,我在 UITableViewRowActionStyle() 上收到一条错误消息:
Missing argument for parameter 'rawValue' in call
有人知道在这种情况下 Swift 3 的语法是什么吗?
像枚举一样使用 UITableViewRowActionStyle。如果您键入它,您将看到多个选项:
UITableViewRowActionStyle.Default
UITableViewRowActionStyle.Destructive
UITableViewRowActionStyle.Normal
let delBut = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: delete_InLocal) { action, index in
}
有时仅 "special" 案例以这种方式提供...您必须使用 rawValue: 0 来表示默认行为
在 Swift 3.
中,从一些导入的枚举类型中删除了默认初始化程序
使用 UITableViewRowActionStyle.default
(或者在您的情况下只需 .default
)而不是 UITableViewRowActionStyle()
。
let delBut = UITableViewRowAction(style: .default, title: delete_InLocal) { action, index in
当我滑动 UITableView 单元格时,调用以下代码:
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
//Problem code
let delBut = UITableViewRowAction(style: UITableViewRowActionStyle(), title: delete_InLocal) { action, index in
//Setup
现在我已经开始迁移到 Swift 3,我在 UITableViewRowActionStyle() 上收到一条错误消息:
Missing argument for parameter 'rawValue' in call
有人知道在这种情况下 Swift 3 的语法是什么吗?
像枚举一样使用 UITableViewRowActionStyle。如果您键入它,您将看到多个选项:
UITableViewRowActionStyle.Default
UITableViewRowActionStyle.Destructive
UITableViewRowActionStyle.Normal
let delBut = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: delete_InLocal) { action, index in
}
有时仅 "special" 案例以这种方式提供...您必须使用 rawValue: 0 来表示默认行为
在 Swift 3.
中,从一些导入的枚举类型中删除了默认初始化程序使用 UITableViewRowActionStyle.default
(或者在您的情况下只需 .default
)而不是 UITableViewRowActionStyle()
。
let delBut = UITableViewRowAction(style: .default, title: delete_InLocal) { action, index in