我有 UITableViewCell,单击它会显示从 .xib 文件加载的 UIView。当我单击单元格时,视图已成功显示,但是我想在视图元素中显示的数据不会显示。
代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic
NSLog(@"didSelectRowAtIndexPath");
//Initialize a UIView that contains all the elements required to display the data
EventDescriptionView *dView = [[EventDescriptionView alloc] init];
//Set the data in the elements to the data contained in the xml
//Set up the cell
int storyIndex = indexPath.row;
[[dView name] setText:[[stories objectAtIndex: storyIndex] objectForKey: @"title"]];
[[dView date] setText:[[stories objectAtIndex: storyIndex] objectForKey: @"date"]];
NSLog(@"Index: %d", storyIndex);
[[dView image] setImage:[images objectAtIndex:storyIndex]];
//Display the UIView
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
[self.view addSubview:dView.view];
[UIView commitAnimations];
}
我可以看到以下线条:
[[dView name] setText:[[stories objectAtIndex: storyIndex] objectForKey: @"title"]];
[[dView date] setText:[[stories objectAtIndex: storyIndex] objectForKey: @"date"]];
NSLog(@"Index: %d", storyIndex);
[[dView image] setImage:[images objectAtIndex:storyIndex]];
没有识别 dView 元素并因此成功设置数据,但我不明白如何解决这个问题?
谢谢,
杰克