1
我正在构建一个带有充当rootViewController的标签栏的向下钻取应用程序。除了详细视图外,该应用程序功能正常。我在我的.plist中概述了三个属性:标题,相关图像和行业信息。如何引用详细控制器中的属性列表?
所以我在头文件中创建这些变量:
@interface DetailView : UIViewController {
NSDictionary *industryData;
IBOutlet UILabel *titleLabel;
IBOutlet UIImageView *associatedImage;
IBOutlet UITextView *industryInfo;
}
@property (nonatomic, retain) NSDictionary *industryData;
@property (nonatomic, retain) IBOutlet UILabel *titleLabel;
@property (nonatomic, retain) IBOutlet UIImageView *associatedImage;
@property (nonatomic, retain) IBOutlet UITextView *industryInfo;
@end
我敢肯定,我是能够得到的viewDidLoad方法右边的第二个部分,但我无法得到它的关联与我的.plist。尽管如此,我仍然对第一部分感到困惑:
{
NSString *Path = [[NSBundle mainBundle] bundlePath];
NSString *DataPath = [Path stringByAppendingPathComponent:@"IndustryData.plist"];
NSDictionary *tempDict = [[NSDictionary alloc] initWithContentsOfFile:DataPath];
self.industryData = tempDict;
[tempDict release];
associatedImage.image = [UIImage imageNamed:[industryData valueForKey:@"Associated Image"]];
titleLabel.text = [industryData valueForKey:@"Title"];
industryInfo.text = [industryData valueForKey:@"Industry Info"];
[super viewDidLoad];
}
我想我的问题是根源于前五行代码。我试图将我对导航部分所做的操作应用到详细视图,但是当它加载时屏幕上没有任何内容。我如何得到我的细节与我的原始.plist关联?
编辑:
我想这是值得加入,从我的“IndustryView”,又名导航的视图控制器:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//Get the dictionary of the selected data source.
NSDictionary *dictionary = [self.tableDataSource objectAtIndex:indexPath.row];
//Get the children of the present item.
NSArray *Children = [dictionary objectForKey:@"Children"];
Dg3_z_Z4_8AppDelegate *AppDelegate = (Dg3_z_Z4_8AppDelegate *) [[UIApplication sharedApplication] delegate];
if([Children count] == 0) {
DetailView *dvController = [[DetailView alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]];
[AppDelegate.indNavControl pushViewController:dvController animated:YES];
[dvController release];
}
有一个else部分,但在这里是不是特别相关。谢谢!
你可以NSLog的行业数据的内容,这将缩小问题的可能范围?另外,不知道你期望发生什么,但看起来你的所有细节视图都会显示相同的数据,因为它读取一个硬编码的plist。 – jrturton