我有一个“FairListViewController”。这是第一个ViewController。在这里通过触摸tableCell,我可以转到下一个是“MenuViewController”。还有两个Button,“ProductViewController”的“Product”和“EventViewController”的“Events”。我在appDelegate中使用“NavigationController”作为“rootViewController”。现在,当我触摸“MenuViewController”中的“Product”按钮时,将我带到“ProductViewController”并触摸“BackButton”,它会顺利回到“MenuViewController”。我为“ProductViewController”做了相同的代码,这里它带我到“EventViewController”但是在触摸“BackButton”之后,奇怪的是它回到了First Page,即“FairListViewController”。我多次更改了我的IBAction按钮名称(在“EventViewController”nib文件中)的名称。重新连接nib文件,甚至从nib文件中删除按钮并尝试使用新按钮,但结果是一样的!以前任何人都可以类似这个问题。任何建议都会非常值得赞赏。非常感谢提前。
这是我的代码:
在MenuViewController中(对于ProductViewController按钮):
- (IBAction)callProductGroups:(id)sender
{
ProductGroupViewController *productGroupViewController;
if(IS_IPHONE_5)
{
productGroupViewController = [[ProductGroupViewController alloc] initWithNibName:@"ProductGroupViewController" bundle:nil];
}
else
{
productGroupViewController = [[ProductGroupViewController alloc] initWithNibName:@"ProductGroupViewControlleriPhone4" bundle:nil];
}
productGroupViewController.topBarImageForAll = self.topBarImageForAll;
productGroupViewController.topBarButtonImageForAll = self.topBarButtonImageForAll;
productGroupViewController.buttonDividerImageForAll = self.buttonDividerImageForAll;
productGroupViewController.backgroundImageForAll = self.backgroundImageForAll;
productGroupViewController.backgroundImageiPhone4ForAll = self.backgroundImageiPhone4ForAll;
[self.navigationController pushViewController:productGroupViewController animated:YES];
}
在ProductViewController中:
-(IBAction)goBack:(id)sender
{
[self.navigationController popViewControllerAnimated:YES];
}
在MenuViewController中(对于EventViewController按钮):
- (IBAction)callEvents:(id)sender
{
EventViewController *eventViewController;
if (IS_IPHONE_5)
{
eventViewController=[[EventViewController alloc] initWithNibName:@"EventViewController" bundle:nil];
}
else
{
eventViewController=[[EventViewController alloc] initWithNibName:@"EventViewControlleriPhone4" bundle:nil];
}
eventViewController.topBarImageForAll = self.topBarImageForAll;
eventViewController.topBarButtonImageForAll = self.topBarButtonImageForAll;
eventViewController.buttonDividerImageForAll = self.buttonDividerImageForAll;
eventViewController.backgroundImageForAll = self.backgroundImageForAll;
eventViewController.backgroundImageiPhone4ForAll = self.backgroundImageiPhone4ForAll;
[self.navigationController pushViewController:eventViewController animated:YES];
}
在EvenViewController中:
- (IBAction)backButton:(id)sender
{
[self.navigationController popToRootViewControllerAnimated:YES];
}
[转到下一个ViewController没有问题,问题是关于回来。]
答案 0 :(得分:0)
Try instead of
[self.navigationController popToRootViewControllerAnimated:YES];
Use
[self.navigationController popViewControllerAnimated:YES];