我正在使用Facebook API,並且當用戶選擇一個地方(CheckIn)時,我想打開另一個視圖並傳遞這個地方(FBGraphPlace),但在「SecondViewController」變量在執行「viewDidLoad」方法時爲null。 當用戶選擇的地方:iOS:在視圖控制器之間傳遞數據
if (secondViewController == nil)
{
SecondViewcontroller *secondViewcontroller =
[[SecondViewcontroller alloc]
initWithNibName:NSStringFromClass([SecondViewcontroller class])
bundle:[NSBundle mainBundle]];
self.secondViewcontroller = secondViewcontroller;
}
// How you reference your navigation controller will
// probably be a little different
UIBarButtonItem *newBackButton = [[UIBarButtonItem alloc] initWithTitle: @"Back" style: UIBarButtonItemStyleBordered target: nil action: nil];
[[self navigationItem] setBackBarButtonItem: newBackButton];
secondViewController.place = self.selectedPlace;
[self.navigationController
pushViewController:self.secondViewcontroller
animated:YES];
爲什麼你有這樣的:baladaViewController.place = self.selectedPlace;當你推secondViewController?不應該是secondViewController.place = self.selectedPlace? – rdelmar 2013-02-14 01:18:02
對不起,錯了......編輯我的帖子。 – 2013-02-14 01:22:55
你確定self.selectedPlace不是零嗎? – rdelmar 2013-02-14 01:24:23