建物情報 (文字列) を保持する Building クラスがあります。DetailViewController を (tableviewcontroller からではなく) プッシュすると、それを使用して建物をプッシュすると、正しい情報が読み込まれます。私がやりたいことは、建物の次のインスタンスで読み込まれるボタンを詳細ビューに表示することです。次のことを試しましたが、うまくいきませんでした。すべてのデータが空白/null になります。建物の配列に適切に接続していないに違いありません。
私のmainViewControllerで
-(IBAction)pushDetailsVC:(id)sender {
DetailViewController* controller = [[DetailViewController alloc] init];
// Pass the Building object to the controller
building = [self.buildings objectAtIndex:nsu_selBldg];
controller.building = building;
NSLog(@"Building name is now: %@", building);
[self presentModalViewController:controller animated:YES];
[controller.uib_backButton addTarget:self action:@selector(close:) forControlEvents:UIControlEventTouchUpInside];
[controller release];
}
私のDetailViewController // hには
@property (nonatomic, retain) Building *building;
@property (nonatomic, retain) PhotoViewerViewController *photoVC;
//m は
- (void)viewDidLoad
{
[super viewDidLoad];
// This works as expected - the data loads in great.
self.uill_bldgName.text = self.building.name;
self.uitt_bldgInfo.text = self.building.bldgInfo;
self.uiivv_bldgPlan.image = [UIImage imageNamed:self.building.bldgPlan];
self.uiivv_bldgImage.image = [UIImage imageNamed:self.building.bldgImageZoom];
NSLog(@"first name%@",self.building.bldgImageZoom);
}
-(IBAction)nextBldg {
// This does not work - data goes null. PhotoVC is my main view controller and buildings is the array of buildings
building = [photoVC.buildings objectAtIndex:2];
Building *building = building;
NSLog(@"building %@",building);
NSLog(@"building %@",[photoVC.buildings objectAtIndex:2]);
self.uill_bldgName.text = self.building.name;
self.uitt_bldgInfo.text = self.building.bldgInfo;
self.uiivv_bldgPlan.image = [UIImage imageNamed:self.building.bldgPlan];
self.uiivv_bldgImage.image = [UIImage imageNamed:self.building.bldgImageZoom];
NSLog(@"secon name %@",self.building.bldgImageZoom);
}