工具栏后退按钮不起作用

工具栏后退按钮不起作用

本文介绍了工具栏后退按钮不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用故事板执行一个项目,在一个viewcontroller中,我有一个按钮.当我单击该按钮时,它将移至下一个viewcontroller,但它是单独的xib文件.现在,我尝试向该xib文件添加一个后退按钮,这样我就可以移回我的情节提要,但它对我而言不起作用?

我尝试了以下代码,以便从xib转到情节提要viewcontroller

viewcontrollerOne *list= [self.storyboard instantiateViewControllerWithIdentifier:@"detail"];
[self presentModalViewController:list animated:YES];

请让我知道其不起作用的原因吗?

解决方案

当您要将故事板中的xib移到视图控制器时,此代码将起作用,

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"IDENTIFIER"];
[self.navigationController pushViewController:vc animated:YES];

Iam doing one project using storyboard ,in one viewcontroller i have a button.When i clicked that it will move to next viewcontroller but its a separate xib file. Now i tried to add aback button to that xib file So i can move back to my storyboard but its not working form me ?

I tried following code for moving from xib to storyboard viewcontroller

viewcontrollerOne *list= [self.storyboard instantiateViewControllerWithIdentifier:@"detail"];
[self presentModalViewController:list animated:YES];

please let me know the reason why its not working?

解决方案

This code will work when you want to move from an xib to a viewcontroller in Storyboard,Its working for me.

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"IDENTIFIER"];
[self.navigationController pushViewController:vc animated:YES];

这篇关于工具栏后退按钮不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 21:26