2013-12-08 46 views
0

我在這裏有一個應用程序,要求用戶輸入3個字段。輸入3個字段後,它們將顯示在自定義單元格內的視圖控制器中。只要你喜歡,你可以添加儘可能多的這些事件。然後,您可以選擇單擊某個事件單元以在新的視圖控制器中顯示關於該特定事件的信息。出於某種原因,我所輸入事件的細節完全沒有出現。我只是得到一個空白的控制器屏幕。我似乎無法弄清楚爲什麼,但我認爲我已經在這個控制器中正確實現了代碼。它是否與我創建一個新的Event對象「theEvent」有關?View Controller Not Displaying Details

下面是一些我的代碼(整個項目將在下面的鏈接):

完整的項目:整個項目鏈接刪除

FinalDetailViewController.h

#import <UIKit/UIKit.h> 

@class Event; 

@interface FinalDetailViewController : UITableViewController 

@property (strong, nonatomic) id detailItem; 

@property (strong, nonatomic) Event *event; 
@property (weak, nonatomic) IBOutlet UILabel *detailLabel; 
@property (weak, nonatomic) IBOutlet UILabel *locationLabel; 
@property (weak, nonatomic) IBOutlet UILabel *dateTimeLabel; 

@end 

FinalDetailViewController.m

#import "FinalDetailViewController.h" 
#import "Event.h" 

@interface FinalDetailViewController() 
- (void)configureView; 
@end 

@implementation FinalDetailViewController 

#pragma mark - Managing the detail item 


- (void)configureView 
{ 
    Event *theEvent = self.event; 

    static NSDateFormatter *formatter = nil; 
    if (formatter == nil) { 
     formatter = [[NSDateFormatter alloc] init]; 
     [formatter setDateFormat:@"CCCC, MMMM dd, yyyy hh:mm a"]; 
    } 
    if (theEvent) { 
     self.detailLabel.text = theEvent.detail; 
     self.locationLabel.text = theEvent.location; 
     self.dateTimeLabel.text = [formatter stringFromDate:(NSDate *)theEvent.date]; 
    } 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
    [self configureView]; 
} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

@end 
+0

只注意到您的文件的名稱。你的導師何時完成「最終項目」? –

+0

當我試圖構建你的項目時,我看到錯誤如「錯誤:連接」detailLabel「不能有一個原型對象作爲它的目的地。」您需要將原型單元內的標籤和項目指向「主事件單元」原型單元以外的其他位置。 –

回答

0

它看起來像你打算FinalDetailViewController的表是一個靜態表視圖(因爲你正在做標籤,你只能在一個靜態表中做)。將表視圖更改爲靜態單元格,它應該工作。

+0

完美答案!謝謝! – Willy2414