简体   繁体   中英

How to update the visual aspects of a NSTableCellView?

I have a custom NSTableCellView with 2 NSTextField s, 1 NSProgressIndicator and 2 Buttons.
I want to hide 1 button and the Progress Indicator when I reload the Table. The problem is if my NSTableView is hidden, when I reload it, the visual gets update, otherwise the NSTableCellView stays the same (the progress bar and label continues visible).

Here's an example:
在此处输入图片说明
The first row is updated (I reloaded the Data of the table when it was hidden) but the second is not (I reloaded the Data of the table when it was active and visible).
Any thoughts about this?

Call the table's cellForRowAtIndexPath: method. It will return nil if the cell is not visible.

(Do not mix it up with the delegate method of the same name)

Once you got access to the cell you should be able to typecast it to your custom sub class (you may want to test wether it really is of the appropriate class) and access their properties and deal with them in any way you want.

Sample assuming it is the 3rd row (index 2) of the first section (index 0):

NSUInteger indexArr[] = {0,2};
NSIndexPath *indexPath = [NSIndexPath indexPathWithIndexes:indexArr length:2];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM