I have a Master-Detail application. When the user selects a row in the Master table(MasterViewController
),I want to open another UITableViewController
(DocumentViewController
) and display data here(not in the Detail view).
When I run the application,"numberOfSectionsInTableView
" for DocumentViewController is called but "cellForRowAtIndexPath
" is not called.
The code in DocumentViewController.m is:
- (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;
}
Thanks for the help.
EDIT:- I have set the delegate and datasource properties for the table.The table is declared as "@property (nonatomic,retain) IBOutlet UITableView *docTable;
" in the DocumentViewController.h. I have tried using 'viewwillappear
' as well as 'initwithstyle
' but these doesn't seem to work either.