我正在尝试使用 PList 填充从表视图推送的视图控制器推送的视图控制器。更简单地说:
TableViewController-->DetailViewController-->2ndDetailViewController(<-这是我要填充的那个)
我尝试这样做的方法是在用户单击表视图中的行时将整数设置为一个值。然后,我将使用该整数的值指向 PList 中的正确值并拉出相应的字符串。在第二个视图控制器中,我试图用 PList 中的图像填充 UIImageView。这是我的 didSelectRowAtIndexPath 的代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DealsDetailViewController *dealsDetail = [[DealsDetailViewController alloc]initWithNibName:@"DealsDetailViewController" bundle:nil];
dealsDetail.dealsImageString = [[self.dealsArray objectAtIndex:indexPath.row] objectForKey:@"Image"];
dealsDetail.dealsLabelString = [[self.dealsArray objectAtIndex:indexPath.row] objectForKey:@"Description"];
dealsDetail.title = [[self.dealsArray objectAtIndex:indexPath.row] objectForKey:@"Name"];
if ([[dealsArray objectAtIndex:indexPath.row] isEqual:@"Deal #1"]) {
dealsDetail.dealsInt = 0;
[dealsDetail setTitle:[dealsArray objectAtIndex:indexPath.row]];
}
if ([[dealsArray objectAtIndex:indexPath.row] isEqual:@"Deal #2"]) {
dealsDetail.dealsInt = 1;
[dealsDetail setTitle:[dealsArray objectAtIndex:indexPath.row]];
}
if ([[dealsArray objectAtIndex:indexPath.row] isEqual:@"Deal #3"]) {
dealsDetail.dealsInt = 2;
[dealsDetail setTitle:[dealsArray objectAtIndex:indexPath.row]];
}
[self.navigationController pushViewController:dealsDetail animated:YES];
[dealsDetail release];
一切都正确填充。我尝试在表格视图控制器(单击按钮时)和 DealsDetailViewController 的 viewDidLoad 方法中对 dealDetail.dealsInt 的值进行 NSLog 记录。两次,无论我单击哪一行,它都会返回一个值“0”。我的语法哪里出错了?
编辑-------- 这是我注销时得到的信息:
NSLog(@"%@",[dealsArray objectAtIndex:indexPath.row]);
2011-11-28 17:40:59.092 Stores Tab Bar[7386:207] {
Barcode = "SampleBarCode3.png";
Description = "Here's the deal 3";
Image = "FritoTest.png";
Name = "Deal #3";
Thumbnail = "dollars.png";
}
它会注销正确单击的对象的 PList 内容。所以它正在获取正确的信息(我认为这是因为它正确地填充了表格视图和详细视图......)