我有一个包含建筑信息(字符串)的建筑类。当我推动我的 DetailViewController(不是来自 tableviewcontroller)时,我推动了与它一起使用的建筑物,它加载了正确的信息。我想要做的是在下一个构建实例中加载的详细视图上有一个按钮。我尝试了以下但没有运气 - 所有数据都变为空白/空。我一定没有正确连接到我的建筑物阵列。
在我的 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);
}