我有我的MainViewController这是一个UIViewController类,在这个视图中我有一个表视图和另一个视图嵌入其中。如你所见,我将表视图委托添加到视图控制器。
@interface MainViewController : UIViewController <FlipsideViewControllerDelegate, UITableViewDataSource, UITableViewDelegate> {
现在回到我的问题,这个问题已经在互联网上搜索了大约50次,但我仍然没有找到解决方案。
为什么reloadData不能工作…?
我正在从XML提要下载信息,我从应用程序委托刷新提要:
- (void)applicationDidBecomeActive:(UIApplication *)application
我插入了多个nlog,这是我发现的。从XML提要中刷新的数据没有问题。但是表格视图单元格没有被刷新。
我放置了一个NSLog in:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
虽然数据正在刷新,当我调用[tableView reloadData];cellForRowAtIndexPath永远不会被调用。
我希望有人能帮助我解决这个问题,我已经在这个问题上工作了大约12个小时,没有运气。我已经用尽了多个站点的搜索按钮....
供参考:-表视图在接口生成器中连接。
-我的表正在通过TableViewCells一个接一个地加载,跟随苹果的例子开始在第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;
}
Thanks for the help
你有代码示例吗?
我第一个想法:
- 数据源未连接
- Section给出0返回
- Sections返回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];
}