未调用cellForRowAtIndexPath

时间:2012-08-20 04:16:58

标签: xcode uitableview

我有一个 Master-Detail 应用程序。当用户在主表MasterViewController)中选择一行时,我想打开另一个UITableViewControllerDocumentViewController)并在此处显示数据(不在详细信息视图中)。

当我运行应用程序时,会调用 DocumentViewController 的“numberOfSectionsInTableView”,但不会调用“cellForRowAtIndexPath”。

DocumentViewController.m 中的代码是:

 - (void)viewDidLoad
{
  [super viewDidLoad];
  [docTable setDataSource:self];
  [docTable setDelegate:self];

EDViPadDocSyncService *service = [[EDViPadDocSyncService alloc]init];
EDVCategory *cat = [EDVCategory alloc];
cat.categoryId = [catId intValue];
[service getDocsByCatId:self action:@selector(getDocsByCatIdHandler:) category:cat];

[self.docTable reloadData];
}

 - (void) getDocsByCatIdHandler: (id)value {
      //snip......
      [docTable reloadData];
}

- (void)viewDidUnload
{
   [super viewDidUnload];
}


 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
   return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
   return [self.myDocList count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   DocumentCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DocumentCell"];
   if (cell == nil)
   {
      cell = [[[DocumentCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"DocumentCell"] autorelease];
   }
NSLog(@"cell text=%@",[self.myDocList objectAtIndex:indexPath.row]);
cell.lblDocName.text = [self.myDocList objectAtIndex:indexPath.row];
return cell;

}

感谢您的帮助。

编辑: - 我已经为表设置了委托和数据源属性。该表在 DocumentViewController.h 中声明为“@property (nonatomic,retain) IBOutlet UITableView *docTable;”。我尝试过使用“viewwillappear”以及“initwithstyle”,但这些似乎也无效。

0 个答案:

没有答案