2011-08-17 15 views
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部分,但在這裏是不是特別相關。謝謝!

+0

你可以NSLog的行業數據的內容,這將縮小問題的可能範圍?另外,不知道你期望發生什麼,但看起來你的所有細節視圖都會顯示相同的數據,因爲它讀取一個硬編碼的plist。 – jrturton

回答

0

嘗試

[[NSBundle mainBundle pathForResource:@"IndustryData" ofType:@"plist"] 

或者,有詳細的項目,如您的詳細視圖控制器的性能,並推前設置它們。

相關問題