0

我有一个 UIViewController 类的 MainViewController,在这个视图中我有一个表格视图和另一个嵌入其中的视图。如您所见,我将表视图委托添加到视图控制器。

@interface MainViewController : UIViewController <FlipsideViewControllerDelegate,   UITableViewDataSource, UITableViewDelegate> {

现在我的问题已经从互联网上的多次搜索中被问了大约 50 次,但我仍然无法找到解决方案。

为什么 reloadData 不起作用...?

我正在从 XML 提要下载信息,并从应用委托刷新提要:

- (void)applicationDidBecomeActive:(UIApplication *)application

我已经插入了多个 NSLog,这就是我发现的。来自 XML 提要的刷新数据没有问题。但是表格视图单元格没有被刷新。

我在其中放置了一个 NSLog:

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

虽然数据正在刷新,但当我调用 [tableView reloadData]; cellForRowAtIndexPath 永远不会被调用。

我希望有人可以帮助我解决这个问题,我已经在这个问题上工作了大约 12 个小时,但没有运气。我已经用尽了多个网站上的搜索按钮......

仅供参考: - 表视图在 Interface Builder 中连接。

-我的表格正在通过 TableViewCells 一张一张地加载,遵循 Apples 示例,从 Table View Programming guide 的第 51 页开始。

附加代码:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return 17;
}

谢谢您的帮助

4

2 回答 2

0

你有任何示例代码吗?

我的第一个想法:

  • 数据源未连接
  • 部分中的行返回 0
  • 部分回馈 0
于 2011-09-18T13:45:07.350 回答
0

现在一切正常...这对我来说浪费了很多时间...

- (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];
}
于 2011-09-18T23:55:41.573 回答