Ios5 PerformsgueWithIdentifier导致导航加载不正确
我有两个视图作为NavigationController层次结构的一部分,一个视图显示项目列表,另一个视图允许您编辑项目或添加新项目 在父视图中,我在导航栏右侧有一个add按钮,按下该按钮后,将执行标识为“AddChild”的序列。此外,当用户点击一个表项时,我会执行另一个标识为“EditChild”的segue,所有这些都是在故事板中设置的 如果用户到达父视图(带有项目列表),但还不存在任何项目,我希望通过编程执行“AddChild”序列,因此我在ViewWillDisplay中添加了以下代码:父视图控制器的Ios5 PerformsgueWithIdentifier导致导航加载不正确,ios5,uinavigationcontroller,uistoryboardsegue,Ios5,Uinavigationcontroller,Uistoryboardsegue,我有两个视图作为NavigationController层次结构的一部分,一个视图显示项目列表,另一个视图允许您编辑项目或添加新项目 在父视图中,我在导航栏右侧有一个add按钮,按下该按钮后,将执行标识为“AddChild”的序列。此外,当用户点击一个表项时,我会执行另一个标识为“EditChild”的segue,所有这些都是在故事板中设置的 如果用户到达父视图(带有项目列表),但还不存在任何项目,我希望通过编程执行“AddChild”序列,因此我在ViewWillDisplay中添加了以下代码
// if there are no children, send user to add screen
if (self.childListData.count == 0) {
[self performSegueWithIdentifier:@"AddChild" sender:self];
}
子viewcontroller加载良好,但导航项仍然是previos视图(后退按钮和添加按钮,而不是后退按钮和保存按钮)
这是我的备考方式:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get a reference to our detail view
ChildDetailTableViewController *childDetail = (ChildDetailTableViewController *)[segue destinationViewController];
// Pass the managed object context to the destination view controller
childDetail.managedObjectContext = managedObjectContext;
// If we are editing a child we need to pass some stuff, so check the segue title first
if ([[segue identifier] isEqualToString:@"EditChild"])
{
// Get the row we selected to view
NSInteger selectedIndex = [[self.tableView indexPathForSelectedRow] row];
// Pass the child object from the table that we want to view
childDetail.currentChild = [childListData objectAtIndex:selectedIndex];
}
}
我不确定我错过了什么,所以如果有人能帮我,我将不胜感激