[英]View Controller Not Displaying Details
I have an app here that asks for user input for 3 fields. 我这里有一个应用,要求用户输入3个字段。 After the 3 fields are entered, they are displayed in a view controller inside of a custom cell.
输入3个字段后,它们将显示在自定义单元格内的视图控制器中。 You can add as many of these events as you like.
您可以根据需要添加任意多个事件。 You can then choose to click on an event cell to display the information in a new view controller about that specific event.
然后,您可以选择单击事件单元格,以在新的视图控制器中显示有关该特定事件的信息。 For some reason, the details for the events I have entered are not showing up at all.
由于某些原因,我输入的事件的详细信息根本没有显示。 I just get a blank controller screen.
我刚得到一个空白的控制器屏幕。 I can't seem to figure out why, but I thought I had the code correctly implemented in this controller.
我似乎无法弄清楚为什么,但是我想我已经在此控制器中正确实现了代码。 Does it have to do with my creation of a new Event object "theEvent"?
它与我创建新的事件对象“ theEvent”有关吗?
Here is some of my code (the full project will be linked below): 这是我的一些代码(完整的项目将在下面链接):
Full Project: Full Project Link Removed 完整项目: 删除完整项目链接
FinalDetailViewController.h 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 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
It looks like you intended to make the FinalDetailViewController's table be a static table view (since you're making outlets to the labels, which you can only do in a static table). 看起来您打算使FinalDetailViewController的表成为静态表视图(因为您正在制作标签的出口,所以只能在静态表中执行此操作)。 Change the table view to static cells, and it should work.
将表视图更改为静态单元格,它应该可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.