NSTableView: only numberOfRowsInTableView: datasource is called

拜拜、爱过 提交于 2019-12-08 07:32:37

问题


I met a problem about the NSTableView, and it is like: one datasource of tableview is called:

- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{
    return [self.dataArray count];
}

But this one is never called:

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
    // the code 
}

I have checked the the array really had data, and also checked the [NSTableView reloadData] was called in the main thread.

SO I'm totally lost about this weird problem. Would any one give some tips? thanks!


回答1:


I moved the initial code from awakeFromNib to the init, and it called correctly. But I still don't know the real reason. I guess it matters with the life-cycle of the view because the class which has the tableview is a subclass of NSObject and not of NSViewController.



来源:https://stackoverflow.com/questions/12245113/nstableview-only-numberofrowsintableview-datasource-is-called

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