Using NSTableView Animations with Bindings

前端 未结 5 1167
滥情空心
滥情空心 2020-12-25 08:26

I have a NSTableView that is bound to a NSArrayController. The NSArrayController\'s contentSet property is bound to a

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-25 09:19

    The model needs to be updated right after the animation is complete:

    @IBAction func onRemoveClick(sender: AnyObject?) {
        let selection = listController.selectionIndexes
        NSAnimationContext.runAnimationGroup({
            context in
            self.tableView.removeRowsAtIndexes(selection, withAnimation: .EffectFade | .SlideUp)
        }, completionHandler: {
            self.listController.removeObjectsAtArrangedObjectIndexes(selection)
        })
    }
    

    Works in my app with bindings. Tested on OS X 10.9, 10.10 & 10.11.

提交回复
热议问题