當創建一個新的視圖控制器被推入堆棧時,用什麼正確的方法來用數據填充視圖控制器?ios - 用數據填充一個新的視圖控制器
我有一個數據對象,我需要發送到視圖控制器,然後將其設置文本字段等數據。
ItemDetailViewController_iPad *detailViewController = [[ItemDetailViewController_iPad alloc] initWithNibName:@"ItemDetailViewController_iPad" bundle:nil];
[detailViewController populateWithData:_data];
[self.navigationController pushViewController:detailViewController animated:YES];
在ItemDetailViewController_iPad:
-(void) populateWithData:(Item*)_data
{
self.data = _data;
self.navigationItem.title = self.data.title;
self.descriptionText.text = self.data.desc; //the text does not get updated - it's the default text from the nib file
NSLog(@"Desc: %@", self.data.desc); //this logs valid data
}