テーブルビューセルに接続されている詳細ビューコントローラがあります。私はデータモデルを持っています。それは私がそれらに必要とするすべての私の財産でありNSObject
、意志を持っています。NSMutableArray
にラベルを@property
付けて名前を付けましたquestionLabel
。何らかの理由で、詳細ビューに移動すると、のデータモデルに入力した質問が表示されませんNSMutableArray
。
最初はセグエが機能していないと思っていましたが、ナビゲーションバーのタイトルを変更しようとすると、からデータを渡したときに機能しました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;
}
}
detailView
- (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
ます。