NSTableView:只有numberOfRowsInTableView:datasource被调用 [英] NSTableView: only numberOfRowsInTableView: datasource is called

查看:343
本文介绍了NSTableView:只有numberOfRowsInTableView:datasource被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个关于 NSTableView 的问题,它就像:
tableview的一个数据源被调用:

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];
}

但是这个不会被调用:

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

我已经检查数组真的有数据,
[NSTableView reloadData] 在主线程中调用。

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!

推荐答案

我从 awakeFromNib init ,它被正确调用。但我还是不知道真正的原因。我想这与视图的生命周期有关,因为有tableview的类是 NSObject 的子类,而不是 NSViewController

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.

这篇关于NSTableView:只有numberOfRowsInTableView:datasource被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆