在故事板中,我有3個視圖控制器:firstViewController
,secondViewController
和controllerA
。介紹另一個不是父級的視圖控制器
firstViewController和secondViewController都有一個導航右欄項目,它向storyboard中的segues呈現controllerA。
controllerA
有一個tableView與自定義表格單元格。在customTableCell.xib中,有一個acceptButton用於存儲數據並彈出回到firstViewController。只有當用戶通過使用popViewController從firstViewController轉到controllerA時,我才能實現此功能。
編輯:但我不能夠做到這一點,如果用戶從secondViewController獲取ControllerA,因爲popToViewController不會工作。我試着使用:
FirstViewController *recordViewController = [[FirstViewController alloc] init];
[self.navigationController pushViewController:recordViewController
animated:YES];
編輯:我得到一個崩潰,此錯誤:
__NSArrayM insertObject:atIndex:]: object cannot be nil'
[SecondViewController recordCardNumber:recordCheckInID:]: unrecognized selector sent to instance 0x17d97250'
有controllerA和firstViewController之間的代理關係。
我該如何正確實施?
編輯:這是FirstViewController委託:
#pragma mark - ControllerADelegate
- (void)recordCardNumber:(NSString *)number recordCheckInID:(NSString *)checkInID
{
self.CardNumbertext.text = number;
NSLog(@"record card# %@", self.CardNumbertext.text);
}
我傳遞的數據通過啪成功,如果我用
[self.delegate recordCardNumber:number recordCheckInID:checkInID ];
[self.navigationController popViewControllerAnimated:YES];
它只是崩潰firstViewController如果我從SecondViewController進入controllerA因爲一旦acceptButton被按下,我想回到firstViewController。
是這個作品,如果我是進入ControllerA從firstViewController,但它不是我要找的,如果我去ControllerA從secondViewController因爲我要彈回至firstViewController的每一次點擊中我的CustomTableCell按鈕。 – user3178926
我更新了我的答案,查看了一下。 – RaffAl
感謝您的幫助。但我認爲它會崩潰,因爲firstViewController和controllerA之間有一個委託。錯誤消息: - [FirstViewController recordCardNumber:recordCheckInID:]:無法識別的選擇發送到實例0xa503650 – user3178926