开发者

UITableView -> numberOfRowsInSection:(NSInteger)section returns wrong value

My 2nd time today... But here are so many good developers...

Hi,

I have some troubles with my tableView... If the view will appear my table reloads its data, but it doesn't update the numbersOfRowsInSection...

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSLog(@"COUNTER: %i",[content count]);
    return [content count];
}

The log says the first time I load the page the right value. But if I add an object 开发者_如何学Cand reload the data, this function isn't calling.

Is there anyone who know the solution?

Thanks, mavrick3.

EDIT:

Heres how I call [table reloadData]

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    if ([content count] != 0) {
        self.content = [[[[NSArray alloc] initWithContentsOfFile:[FileManager filePath]] objectAtIndex:row_] objectForKey:@"faecher"];
        [table reloadData];
        NSLog(@"----%@",content);
    }
}

And yes, the dataSource and delegate are connected and they are both implemented in my header.


If you call reloadData on a UITableview object and you're it's dataSource then this method should be called called.

Are you sure that you have assigned your table view to your property (i.e. dragged it across in interface builder?)

I suspect that you have only made your controller the dataSource of your table view (hence the first time it loads it gets the value). After that your calls to reloadData won't work because the property in your view controller is still nil.


You can test this by putting an NSLog just before you call reloadData - if it outputs nil then you've not connected it.

NSLog(@"%@", myTable);
[myTable reloadData];


any compiler warnings? Is "table" actually an instance of UITableView?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜