Ios navigationController PopViewController无效

Ios navigationController PopViewController无效,ios,objective-c,Ios,Objective C,我是ios开发新手,我想在我的应用程序中添加后退按钮。 为此,我在-viewdidLoad中编写代码: 我使用popViewController返回 Clickevent代码为: -(IBAction)OnClick_btnBack:(id)sender { [self.navigationController popViewControllerAnimated:YES]; } 但当我点击按钮时,事件触发,但没有变化出现 我已经试过了: -[self.navigationContro

我是ios开发新手,我想在我的应用程序中添加后退按钮。 为此,我在-viewdidLoad中编写代码:

我使用popViewController返回 Clickevent代码为:

-(IBAction)OnClick_btnBack:(id)sender  {
    [self.navigationController popViewControllerAnimated:YES];
}
但当我点击按钮时,事件触发,但没有变化出现

我已经试过了:

-[self.navigationController pushViewController:self.navigationController.parentViewController animated:YES];

-[self.parentViewController.navigationController popToRootViewControllerAnimated:YES];

-[self dismissViewControllerAnimated:YES completion:nil];

但这3个也不起作用。有没有其他办法来解决这个问题

看起来您正在重新创建故事板中已有的按钮。如果不是,则您有一个iAction连接到故事板中的某个内容。将括号中的iAction更改为void,这将修复它


还有…为什么不使用自定义方法创建Uibarbutton,并在其中设置图像?

如果说某个东西不起作用,则无法提供任何信息。解释按下按钮时发生的情况。按钮没有显示吗?它是去错控制器了吗?它正在发生,但没有动画?我编辑了我的问题,请参考..我只想澄清事件触发,我已经检查了,但代码不起作用请检查viewController的层次结构。是的,viewController层次结构是正确的..我只是检查方法是否被称为NSLog导航控制器:NSLog%@,自导航控制器;是..我已将iAction更改为void,但未找到任何更改..后退按钮不起作用..还尝试了UIbarbutton,但没有任何效果..单击事件激发,但不转到上一屏幕…是否有其他解决方案???请提供帮助您是否有情节提要?没有任何情节提要或xib,只有.h和.m文件…我有一个现有的应用程序,我必须对其进行一些更改。导航控制器右侧的“放回”按钮就是其中之一…@VidhiTrivedi构建应用程序的有趣方式。我认为故事板很容易使用!特别是在这样的情况下。你是绝对正确的,但在现有的应用程序中我不能使用它,请给出另一个解决方案。对这个小问题完全失望。帮助我。提前谢谢
-[self.navigationController pushViewController:self.navigationController.parentViewController animated:YES];

-[self.parentViewController.navigationController popToRootViewControllerAnimated:YES];

-[self dismissViewControllerAnimated:YES completion:nil];