Objective c UITableView单元格空白

Objective c UITableView单元格空白,objective-c,ios,ios4,Objective C,Ios,Ios4,意外删除.m文件后,我正在尝试恢复。有人看到我做错了什么导致我的单元格全部呈现为空白吗 H 更新: 我把它归咎于一个奇怪的问题。在下面的示例中,我以10的身份注销,但如果返回i,则行显示为空。如果我返回10,如下所示,它就工作了 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { #warning Incomplete method implementatio

意外删除.m文件后,我正在尝试恢复。有人看到我做错了什么导致我的单元格全部呈现为空白吗

H 更新:

我把它归咎于一个奇怪的问题。在下面的示例中,我以10的身份注销,但如果返回i,则行显示为空。如果我返回10,如下所示,它就工作了

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    #warning Incomplete method implementation.
    // Return the number of rows in the section.
    NSInteger i = [[Shared sharedInstance].messages count];
    NSLog([NSString stringWithFormat:@"Number of rows %i", i]);
    return 10;
}
另一更新:

好的,我已经接近了。虽然在我使用调试器时会调用重载数据,但它似乎并没有正确地重载。这就是为什么如果我对每一行使用硬编码的样本字符串,硬编码的数字就会起作用。第一次加载时,行数将为零,由于重新加载数据不起作用,因此下次加载时不会更新为10行。
以防有人怀疑我是否连接到委托和数据源


如果您使用的是XIB,请确保您的连接已建立,并且它们指向
UITableView


此外,当您使用UITableViewController时,无需使用
协议。

可以有很多功能。你连接了tableview委托和数据源属性了吗?是的,它们附加到文件所有者,我将xib视图设置为UITableView。你在委托方法中将tableview中的节数设置为1了吗?我没有,但我只是做了以下操作:
-(NSInteger)numberOfSectionsInTableView:(UITableView*)tableview{return 1;}
该表是否实际返回任何单元格(返回的单元格是否在表中可见),还是只看到一个空表?如果返回单元格,是否尝试更改textLabel的字体颜色?完成,完成,完成。我想这和我的编辑有关。如果我返回一个数字,而不是一个存储有数字的int型变量,它就工作了。不幸的是,我必须让它成为一个变量。好吧,我已经更接近了,并发布了另一个更新,以防这有所帮助。重新加载似乎不像广告中所说的那样有效。如果不添加任何额外的插座,实际上您甚至不需要XIB,因此您可以删除XIB以减少混乱。解决了!在以前的一次XIB中,我在XIB名称中列出了错误的名称。我不确定为什么它没有产生错误,只是似乎对这一个有影响。
#import "FirstViewController.h"
#import "Shared.h"
#import "Message.h"

@implementation FirstViewController

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"CellIdentifier";

    // Dequeue or create a cell of the appropriate type.
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
        cell.textLabel.text = @"Foo"; 
    return cell;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    NSLog([NSString stringWithFormat:@"Number of rows %i", [[Shared sharedInstance].messages count]]);
    //this comes back as 10
    return [[Shared sharedInstance].messages count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    #warning Incomplete method implementation.
    // Return the number of rows in the section.
    NSInteger i = [[Shared sharedInstance].messages count];
    NSLog([NSString stringWithFormat:@"Number of rows %i", i]);
    return 10;
}