-1

UILabel在故事板中创建了一个。

我的.h 文件

@interface EditAndControll : UIViewController

@property (strong, nonatomic) id detailItem;
@property (strong, nonatomic) IBOutlet UILabel *deviceDetailLabel;

- (void)configureView;
@end

我的.m 文件

@implementation EditAndControll
@synthesize detailItem = _detailItem;
@synthesize deviceDetailLabel = _deviceDetailLabel;

- (void)setDetailItem:(id)newDetailItem
{
if (_detailItem != newDetailItem) {
    _detailItem = newDetailItem;

    // Update the view.
    [self configureView];
}
}

- (void)configureView
{

    if (self.detailItem)
{
    DeviceCoreInfo *detailDevice = [DeviceCoreInfo alloc];
    detailDevice = self.detailItem;
    _deviceDetailLabel.text = detailDevice.deviceIP;
    self.deviceDetailLabel.text=detailDevice.deviceIP;
    NSLog(@"Device Label %@",_deviceDetailLabel);
    NSLog(@"self Device LaBel %@", self.deviceDetailLabel);
}

}

NSLog 告诉我:

Device Label (null)

self Device LaBel (null)

我从主视图调用的所有内容:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showDetail"]) {
    NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
    NSManagedObject *selectedObject = [[self fetchedResultsController]      objectAtIndexPath:indexPath];
    [[segue destinationViewController] setDetailItem:selectedObject];
}
}

我做错了什么?请帮忙!

4

1 回答 1

0

Hey Check Form 你在哪里调用这个- (void)configureView方法。

您需要将该方法称为

- (void)viewDidLoad {
   // configureView method From here.
}

谢谢

于 2012-11-20T10:30:11.907 回答