設定:
MainViewControllerオブジェクトの を保持しNSMutableArrayます。オブジェクトは、 aとivarNewContactを持つmy のインスタンスです。をタップすると、すべてのオブジェクト ivar (および) がテーブルに表示されます。firstNamecontactImageshowAllContactsBtnMainViewController AllContactsViewControllerfirstNamescontactImages
AllContactsViewController問題は、データを適切に渡さないが、修正方法がわからないことだと思います。言及する価値があるのは、 NSLogステートメントが表示されcellForRowAtIndexないため、メソッドがまったく呼び出されない可能性があることです。
MainViewController.m
- (IBAction)showAllCBtnTapped:(id)sender
{
AllContactsViewController *nAllCVC = [[AllContactsViewController alloc]init];
nAllCVC.allContactsArray = self.contactsArray; // Properly passed the data???
nAllCVC.delegate = self;
nAllCVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:nAllCVC animated:YES];
}
AllContactsViewController.h
@interface AllContactsViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
AllContactsViewController.m
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdent = @"ContactCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdent];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdent];
}
NewContact *tempContact = [[NewContact alloc]init];
tempContact = [self.allContactsArray objectAtIndex:[indexPath row]];
cell.textLabel.text = tempContact.firstName;
NSLog(@"%@", tempContact.firstName);
NSLog(@"Test......");
cell.imageView.image = tempContact.contactPicture;
[tableView reloadData];
return cell;
}
ノート:
AllContactsViewControllerからサブクラス化されていることがわかりますが、デリゲートとデータソースを適切に設定したにもかかわらずUIVIewController、からサブクラス化する必要がありますか?UITableViewController