uitableview cellforrowatindexpath未调用,但no:of节中的行被调用 [英] uitableview cellforrowatindexpath not called but no:of rows in section is called

查看:75
本文介绍了uitableview cellforrowatindexpath未调用,但no:of节中的行被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的tableview中,节方法中没有行被调用,并且它返回值17,但是未调用cellforrowatindexpath.我已经在该方法的第一行中放置了断点,但是调试时从不显示该点,我有接下来是tableviewdelegate和datasource.在Int构建器中正确设置了tableviews数据源,delegate.

in my tableview no of rows in section method is called and it returns value 17,but the cellforrowatindexpath is not getting called.i have put breakpoints in the first line of this method but this point is never shown when debugging,i have followed the tableviewdelegate and datasource.and the tableviews datasource,delegate are properly set in the Int builder.

我也在发布一些代码

在我的viewcontroller.m

in my viewcontroller.m

-(void)viewDidLoad
{

        tweets=[[NSMutableArray alloc]init];
        [self updateStream:nil];
        [self.tweetsTable setDelegate:self];
        [self.tweetsTable setDataSource:self];

}


-(NSInteger)tableView:(UITableView *)tweetsTable numberOfRowsInSection:(NSInteger)section {

    return [tweets count];

}

-(UITableViewCell *)tableView:(UITableView *)tweetsTable cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"twitCell";
    TwitCell *cell = (TwitCell *)[tweetsTable dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = (TwitCell *)[[[TwitCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];   
    }
    cell.tweet = [tweets objectAtIndex:indexPath.row];
    [cell layoutSubviews];
    return cell;
}

推荐答案

cellForRowAtIndexPath如果表视图的高度为0,则不会调用

cellForRowAtIndexPath won't get called if your tableview has height of 0

确保您的表视图始终具有可见行

make sure your tableview always has VISIBLE rows

CGRect frame = self.tableView.frame;
frame.size.height = 100;
self.table.frame = frame;

这篇关于uitableview cellforrowatindexpath未调用,但no:of节中的行被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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