1

在故事板中,我有3個視圖控制器:firstViewController,secondViewControllercontrollerA介紹另一個不是父級的視圖控制器

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。

回答

0

要顯示按鈕水龍頭的第一個視圖控制器:

FirstViewController *recordViewController = [[FirstViewController alloc] init]; 
[self.navigationController pushViewController:recordViewController 
            animated:YES]; 

但是,錯誤的原因給你:

__NSArrayM insertObject:atIndex:]: object cannot be nil

是最有可能不是彈出來一個視圖控制器連接但更新按鈕水龍頭上的數組。檢查點擊按鈕時觸發的代碼。最有可能的是你添加了一個對象,該對象是NSMutableArray

+0

是這個作品,如果我是進入ControllerA從firstViewController,但它不是我要找的,如果我去ControllerA從secondViewController因爲我要彈回至firstViewController的每一次點擊中我的CustomTableCell按鈕。 – user3178926

+0

我更新了我的答案,查看了一下。 – RaffAl

+0

感謝您的幫助。但我認爲它會崩潰,因爲firstViewController和controllerA之間有一個委託。錯誤消息: - [FirstViewController recordCardNumber:recordCheckInID:]:無法識別的選擇發送到實例0xa503650 – user3178926

相關問題