0

の正しい宣言を入力したにもかかわらず、このメッセージが表示され続けるのはUITableViewRowActionなぜですか?

var shareAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Share",
        handler: { (action:UITableViewRowAction!, indexPath: NSIndexPath) -> Void in
4

1 に答える 1

1

Xcode 6.4 のドキュメントには、両方のパラメーターが暗黙的にラップ解除されたオプションである必要があると記載されています。

var shareAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Share",
        handler: { (action: UITableViewRowAction!, indexPath: NSIndexPath!) -> Void in

または Xcode 7 では、どちらのパラメーターもオプションではありません。

var shareAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Share",
        handler: { (action: UITableViewRowAction, indexPath: NSIndexPath) -> Void in

いずれにせよ、あなたは試してみるべきです

var shareAction = UITableViewRowAction(style: .Default, title: "Share") {
    action, indexPath in
    /* ... */
}

これは、より迅速な方法です。

于 2015-09-08T17:54:54.300 に答える