【发布时间】:2014-03-06 20:10:15
【问题描述】:
在故事板中,我有 3 个视图控制器:firstViewController、secondViewController 和 controllerA。
firstViewController 和 secondViewController 都有一个导航右栏项,它使用情节提要中的 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);
}
如果我使用,我正在传递数据并成功弹出到 firstViewController
[self.delegate recordCardNumber:number recordCheckInID:checkInID ];
[self.navigationController popViewControllerAnimated:YES];
如果我从 SecondViewController 输入 controllerA,它就会崩溃,因为我想在按下 acceptButton 后返回到 firstViewController。
【问题讨论】:
标签: ios uiviewcontroller uinavigationcontroller poptoviewcontroller presentviewcontroller