我有一个连接到表格视图单元的详细视图控制器。我有一个数据模型。它是一个NSObject并且拥有NSMutableArray我需要的所有属性。
我将一个标签连接到一个@property并命名它questionLabel。出于某种原因,当我推到详细视图时,它没有显示我在数据模型中为NSMutableArray.
起初我认为 segue 不起作用,但是当我尝试更改导航栏标题时,当我从NSMutableArray.
有人知道我的标签做错了什么吗?
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"pushDetail"])
    {
        // Create an instance of our DetailViewController
        DetailQuestionViewController *DQV = [[DetailQuestionViewController alloc] init];
        NSIndexPath *path = [self.tableView indexPathForSelectedRow];
        // Setting DQV to the destinationViewController of the seque
        DQV = [segue destinationViewController];
        Question *selectedQuestion = [self.myQuestionList questionAtIndex:path.row];
        DQV.questionLabel.text = [selectedQuestion questionName];
        DQV.navigationItem.title = [selectedQuestion questionRowName];
    }
}
更新(对于:adambinsz)
表视图
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"pushDetail"])
    {
        // Create an instance of our DetailViewController
        DetailQuestionViewController *DQV = [[DetailQuestionViewController alloc] init];
        // Setting DQV to the destinationViewController of the seque
        DQV = [segue destinationViewController];
        NSIndexPath *path = [self.tableView indexPathForSelectedRow];
        Question *selectedQuestion = [self.myQuestionList questionAtIndex:path.row];
        DQV.detailItem = selectedQuestion;
    }
}
详细视图
- (void)setDetailItem:(id)newDetailItem
{
    if (_detailItem != newDetailItem) {
        _detailItem = newDetailItem;
        // Update the view.
        [self configureView];
    }
}
- (void)configureView
{
    // Update the user interface for the detail item.
    if (self.detailItem) {
        Question *theQuestion = (Question *)self.detailItem;
        self.questionLabel.text = theQuestion.questionName;
        NSLog(@"The Question's questionName is %@", theQuestion.questionName);
     }
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self configureView];
}
我认为它可能不起作用的原因是因为 if 语句self.detailItem没有正确检查它。
该方法被调用而不是detailItem.