UITableView in UIViewController reloadData not updating table view
I have my MainViewController which a UIViewController class, in this view I have a table view and another view embedded in it. As you can see I added the table view delegates to the view controller.
@interface MainViewController : UIViewController <FlipsideViewControllerDelegate, UITableViewDataSource, UITableViewDelegate> {
Now to my question which has been asked about 50 times from multiple searches on the internet but still I have not been able to find a solution.
Why doesn't reloadData work...?
I am downloading info from an XML feed and I refresh the feed from the app delegate:
- (void)applicationDidBecomeActive:(UIApplication *)application
I have inserted multiple NSLogs, this is what I have found. The refreshed data from the XML feed is coming in no problem. But the table view cells are not being refreshed.
I placed a NSLog in:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
Although the data is being refreshed, when I call [tableView reloadData]; the cellForRowAtIndexPath is never called.
I am hoping someone can help me with this issue, I have been working on this issue for about 12 hours with no luck. I have exhausted the search button on multiple sites....
FYI: -Table View is wired in Interface Builder.
-My tables are being loaded one by one via TableViewCells, following Apples example starting on page 51 of the Table View Programming guide.
Additional Code:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Re开发者_运维技巧turn the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return 17;
}
Thanks for the help
Do you have any example Code ?
My first ideas:
- Datasource not connected
- Rows in Section give 0 back
- Sections give 0 back
Everything is working now... That was a lot of time wasted on my part...
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[_mainViewController refresh];
[_mainViewController.tableView reloadData];
}
- (void)refresh {
Parser *xmlParser = [[Parser alloc] init];
[xmlParser parseRssFeed:@"http://www.somesite.com/file.xml" withDelegate:self];
[xmlParser release];
[self.tableView reloadData];
}
精彩评论