табличное представление отображает дополнительную опцию на событии didSelect - PullRequest
0 голосов
/ 17 октября 2018

Как отобразить опцию прокрутки в uitableview на didselectRow:

, чтобы вывести опцию прокрутки, как показано ниже. enter image description here

Пример шоу на рис., Это должновнедрить в строку didselect.Как можно достичь этого, помогите мне.Заранее спасибо.

1 Ответ

0 голосов
/ 18 октября 2018

Во-первых, вы должны убедиться, что:

func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
    // the cells you would like the actions to appear needs to be editable
    return true
}

func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
    // you need to implement this method too or you can't swipe to display the actions
}

, а во-вторых, вы будете реализовывать в этом методе делегата:

func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? {
    let more = UITableViewRowAction(style: .Normal, title: "More") { action, index in
        println("more button tapped")
    }
    more.backgroundColor = UIColor.lightGrayColor()

    let favorite = UITableViewRowAction(style: .Normal, title: "Favorite") { action, index in
        println("favorite button tapped")
    }
    favorite.backgroundColor = UIColor.orangeColor()

    let share = UITableViewRowAction(style: .Normal, title: "Share") { action, index in
        println("share button tapped")
    }
    share.backgroundColor = UIColor.blueColor()

    return [share, favorite, more]
}

окончательный вид: enter image description here надеюсь, что это полезно для вас.

...