的cellForRowAtIndexPath不叫(cellForRowAtIndexPath not

2019-10-17 03:59发布

我有一个主从应用程序。 当用户在主表 (选择行MasterViewController ),我想打开另一个UITableViewControllerDocumentViewController )和显示数据在这里( 未在详细信息视图 )。

当我运行应用程序,“ numberOfSectionsInTableView ‘为DocumentViewController的调用,但’ 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;

}

谢谢您的帮助。

编辑: -我已经设置了table.The表委托和DataSource属性被声明为“ @property (nonatomic,retain) IBOutlet UITableView *docTable;DocumentViewController.h”。 我一直在使用“试图viewwillappear ”以及“ initwithstyle ”,但这些似乎并没有任何工作。

文章来源: cellForRowAtIndexPath not called