我遇到问题的方法prepareForSegue:sender
我点击单元格时没有从我的Plist加载数据。而且它没有错误。
View.m
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
NSString *identifier = segue.identifier;
if ([identifier isEqualToString:@"DataDetail"]) {
//First get the data
NSIndexPath *selectedIndexPath = self.tableView.indexPathForSelectedRow;
NSMutableDictionary *data = self.datas[selectedIndexPath.row];
DataDetailViewController *dataDetailViewController = segue.destinationViewController;
dataDetailViewController.data = data;
}
}
-(id) initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"plist"];
NSArray *nonMutableBirthdays = [NSArray arrayWithContentsOfFile:plistPath];
self.datas = [NSMutableArray array];
NSMutableDictionary *dataDic;
NSDictionary *dictionary;
NSString *name;
NSString *pic;
UIImage *image;
NSString *detail;
for (int i=0;i<[nonMutableBirthdays count];i++) {
dictionary = [nonMutableBirthdays objectAtIndex:i];
name = dictionary[@"name"];
pic = dictionary[@"pic"];
image = [UIImage imageNamed:pic];
detail= dictionary[@"detail"];
dataDic = [NSMutableDictionary dictionary];
dataDic[@"name"] = name;
dataDic[@"image"] = image;
dataDic[@"detail"] = detail;
[self.datas addObject:dataDic];
}
}
return self;
}
和DataDetailViewController.m
-(void) viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
NSLog(@"viewWillAppear");
NSString *name = self.data[@"name"];
self.title = name;
UIImage *image = self.data[@"image"];
self.photoView.image = image;
NSString *detail = self.data[@"detail"];
self.TextView.text= detail;
}
请帮忙。