开发者

iPhone: UITableView Becomes Invisible after Changing the Data it Displays

I have application with a TabBar that controls several views. In one view, I control connections to different servers. Each server provides a different set of items. I display these items in UITableView on another view.

The problem is that the tableview displays OK the first time but if I go back to view number one and change the server, thereby changing the list of items that should be displayed in tableview, the tableview becomes invisible for some reason. If I tap on the screen in 开发者_运维技巧the place where it should be, it becomes visible again.

I create table view like this

  UITableView * aTableView = [[UITableView alloc] initWithFrame:CGRectMake(X,Y,Width,Height) style:UITableViewStyleGrouped];

  [[self view] addSubview:aTableView];

  aTableView.dataSource = self;

Ive tried to call reloadData and setNeedsDisplay in viewWillAppear of the UIViewController that hosts this tableview but without success.

Any advice?

Thanks


i don't know it will solve your problem or not but you are missing

aTableView.delegate = self;

or you haven't paste it here


I would guess that the problem is that tableview's datasource is not providing the data the first the table reloads after switching servers. If the datasource does not provide any rows, the tableview appears completely blank. That sounds like your issue.

I would look at the code where you switch servers as well as at the tableview:cellForRowAtIndexPath: Set a breakpoint/log there to activate after you switch servers and see what data the datasource is providing immediately after the servers switch. I think you'll find the table has no data. When you touch it, the table forces an update and by that time, the data has arrived.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜