开发者

UITableView lazyload - reloadData not working

this seems to be a classic problem but I couldn't find any thread with a working solution.

I have a UITableView that I want to "lazyload" with some XML loaded from my server.

My UITableView is correctly declared in the .h...

IBOutlet UITableView *tblView;

...

@property (nonatomic, retain) IBOutlet UITableView *tblView;

...connected in the Interface Builder and synthesized in the .m :

@synthesize tblView;

Now... when the viewcontroller loads, the UITableView delegates (numberOfSectionsInTableView, numberOfRowsInSection) get called once. But I don't have any data at this point so these methods return 0.

Once my data is loaded from the server and parsed, I call...

[tblView reloadData]

... but it doesn't have 开发者_JAVA百科any effect. The delegates are not called at all.

I also tried

[[self tblView] reloadData]

And it doesn't work either.

I even tried to issue the call through the performSelectorOnMainThread like this

...

[self performSelectorOnMainThread:@selector(fillTableWith:) withObject:arrAppointmentsFromServer waitUntilDone:NO];

...

- (void)fillTableWith:(NSMutableArray *)arrAppointmentsFromServer
{
    self.arrAppointments = arrAppointmentsFromServer;

    //Calls a refresh of the tableview
    [tblView reloadData];
}

And this doesn't work either.

Any hints or solution?

Thanks in advance


Ok got it...

my view controller actually inherits from UITableViewController...

Therefore I don't have to declare the IBOutlet, synthesize it or whatever...

When it's time to reload the data, I just do :

[[self tableView] reloadData];

because tableView directly refers to the control itself.

Now the numberOfSectionsInTableView and numberOfRowsInSection methods get called correctly

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜