0
我有一个UITableView,我通过initWithFrame动态添加。Code driven UITableView not delegating
- (void)twitterUpdate {
twitterTable = [[UITableView alloc] initWithFrame:CGRectMake(40, 100, 420, 750)];
twitterTable.delegate = self;
twitterTable.backgroundColor = [UIColor clearColor];
twitterTable.separatorColor = [UIColor darkGrayColor];
twitterTable.dataSource = self;
[twitterView addSubview:twitterTable];
}
不幸的是,
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
不会被调用,尽管我曾
<UITableViewDataSource, UITableViewDelegate>
在我的头文件中定义。
任何想法为什么这不叫? twitterUpdate正在通过调用
[self performSelectorOnMainThread:@selector(twitterUpdate) withObject:self waitUntilDone:YES];
并正在将该表绘制到页面。我也有
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
返回一个有效的NSInteger。
你不能动态创建这样的表吗?
你说numberOfRowsInSection返回一个有效NSInteger的...是大于0? – MarkPowell 2011-03-21 18:21:07
是的。我甚至尝试手动设置它。 – 2011-03-21 18:23:47
你真的100%肯定numberOfSectionsInTableView:返回值> 0和tableView:numberOfRowsInSection:返回值> 0为特定部分?因为你可以用这种方式添加UITableView而没有问题。 – robertvojta 2011-03-21 18:26:08