View based NSTableView viewForTableColumn:row not called

岁酱吖の 提交于 2019-12-10 10:52:15

问题


I've got a View-based NSTableView which is configured in IB to be View based. Its column identifier is set, too. As are its dataSource and delegate set, to the same object, which claims to conform to both in the public header. I've verified these are set after the tableView awakes from its nib.

As per the docs, I've implemented -numberOfSectionsInTableView: and it gets called and returns a non-zero number.

However, -tableView:viewForTableColumn:row:, much to my chagrin, does not, and I can't figure out why not.

Does anyone know why this might happen? I'm running on Mountain Lion and my deployment target is also set to be Mountain Lion.


回答1:


It' simple! The problem was, even though the tableview was added to my view hierarchy, it was clipped so it couldn't be seen. NSTableView must do some checks to see if it's actually on screen and then only request cell views for visible rows.

Because the whole tableview was essentially "off-screen", it wouldn't request any rows.




回答2:


My NSTableView is added by code instead of IB, I solved it by adding:

[tableView addTableColumn:[[NSTableColumn alloc]initWithIdentifier:@"columnIdentifier"]]


来源:https://stackoverflow.com/questions/13076847/view-based-nstableview-viewfortablecolumnrow-not-called

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!