CheckBox in tableview

前端 未结 3 1645
孤独总比滥情好
孤独总比滥情好 2021-01-03 10:38

I am facing trouble in putting check boxes into a UITableView. I am posting a part of my code here.

- (NSCell *)tableView:(NSTableView *)tableView dataCellFo         


        
3条回答
  •  北荒
    北荒 (楼主)
    2021-01-03 11:08

    I'm not sure why you're creating the cell in code. You can just drag the cell onto the table column in Interface Builder.

    Also, setObjectValue: is where you respond to the change in the cell's state. The user has already changed the cell's state to off; then you send setNextState and change it back. That's why the cell doesn't appear to uncheck: you keep re-checking it.

    What you need to do is not touch the cell at all, but set the object value (which, for this column, will probably be a Boolean NSNumber containing either YES or NO) as the new value of the appropriate property in your model.

    Also, of course, make sure the column is set as editable.

提交回复
热议问题