我希望禁用按下我的标签栏并返回导航层次结构中的根视图的功能,同时还保留导航栏中按钮的此功能.
因此,我希望用户返回根视图的唯一方法是按导航栏中的按钮而不是点击标签栏按钮.
我已经浏览了一下并尝试了几种解决方案,但似乎都没有工作,因为它们禁用了导航栏按钮和标签栏按钮的功能,而不仅仅是标签栏按钮.
谢谢!
uinavigationcontroller uitabbaritem uitabbar ios poptoviewcontroller
我试图解雇一个被调用的ModaViewController C,回到A.ModalViewController出现在B.因此导航流程为A-> B - (现在的ModalView) - > C.我能够将ModalViewController后退关闭到B,但是我无法在完成括号中弹回A.这是我尝试过的代码:
[self dismissViewControllerAnimated:YES completion:^{
[self.navigationController popToViewController:[[self.navigationController viewControllers] objectAtIndex:0] animated:YES];
}];
Run Code Online (Sandbox Code Playgroud)
ModalViewController被解除但不会弹回A.我在一个代码中调用了这个代码块IBAction.
有什么建议?
在第二个注释,当我解雇ModalViewController所有我UIPickers的控制器B是空的/解除分配.我也在使用ARC.
嗨,我正在开发一个我应该去的应用程序:
UIViewController1到UIViewController2UIViewController2到UIViewController3UIViewController3到UIViewController4UIViewController4回到UIViewController2我在用UINavigationController.当我使用[self.navigationController pushViewController:VC2 animated:NO];,[self.navigationController popViewControllerAnimated:NO];一切正常.
但是当我使用[self.navigationController popToViewController:VC2 animated:NO];从UIViewController4应用程序终止说法Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Tried to pop to a view controller that doesn't exist.'
以下是我的代码如何弹出UIViewController2
for (UIViewController *vc in self.navigationController.viewControllers) {
if ([vc isKindOfClass:[ViewController2 class]]) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
ViewController2 *VC2 = …Run Code Online (Sandbox Code Playgroud) uiviewcontroller uinavigationcontroller ios poptoviewcontroller
我有一个iOS应用程序,主屏幕是UICollectionViewController.从集合视图中选择项目时,视图将被推送到项目的详细视图.在详细视图中,我构建了一个从侧面移出的抽屉/滑块.为了让视图看起来像我想要的方式,我隐藏了默认导航栏并通过故事板插入了一个.
我遇到了一个问题,当隐藏默认导航栏时,您将失去使用导航控制器附带的后退按钮功能.我通过在后退按钮处添加一个按钮来解决这个问题(上面的图像显示没有按钮).现在我使用下面的代码行回到集合视图.
[self.navigationController popToRootViewControllerAnimated:YES];
Run Code Online (Sandbox Code Playgroud)
它以我想要的方式工作,除了当我返回到集合视图时我丢失了导航栏.有没有人对如何解决这个问题有任何想法?提前致谢!
在我的应用程序中,我正在做的是:
rootViewController - > pushViewController - > pushViewController - > pushViewController - > presentModalViewController
从presentModalViewController我想直接去rootViewController.
所以我做的是:
while(theViewController = [theObjectEnumerator nextObject ])
{
if([theViewController modalTransitionStyle] == UIModalTransitionStyleCoverVertical)
{
[self.mNavigationController popToRootViewControllerAnimated:
YES];
}
}
}else
while(theViewController = [theObjectEnumerator nextObject ])
{
if([theViewController modalTransitionStyle] == UIModalTransitionStyleCoverVertical)
{
[self.mNavigationController dismissModalViewControllerAnimated:YES];
}
}
Run Code Online (Sandbox Code Playgroud)
但在这里我收到一条消息
警告:在演示或解雇过程中尝试从视图控制器中解除!
并在此应用程序崩溃后.
我搜索了这个,但找不到对我有用的东西,任何机构都可以解释为什么会这样吗?
objective-c uinavigationcontroller presentmodalviewcontroller ios poptoviewcontroller
在我的应用程序中,我有三个表视图控制器,然后可能有许多UIViewControllers,如果用户在任何时候按下,每个UIViewControllers都必须返回到第一个表视图控制器.我不希望用户必须回溯可能数百页.这是我有趣的,以确定用户是否按下后退按钮,它的工作原理是打印消息
override func viewWillDisappear(_ animated: Bool) {
if !movingForward {
print("moving back")
let startvc = self.storyboard!.instantiateViewController(withIdentifier: "FirstTableViewController")
_ = self.navigationController!.popToViewController(startvc, animated: true)
}
}
Run Code Online (Sandbox Code Playgroud)
我已经搜索过,到目前为止还没有解决方案.
我在LocationVC ViewController上有一个变量“ NameofCircle”,并且在此Controller上有变量CName,我想通过popToViewController将CName值传递给LocationVC Controller。我尝试了下面的代码,但没有得到结果。
let viewControllers = self.navigationController!.viewControllers
for aViewController in viewControllers
{
if aViewController is LocationVC
{
let Location = LocationVC()
Location.NameofCircle = CName
_ = self.navigationController?.popToViewController(aViewController, animated: true)
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试做的是将所有以前的视图控制器从堆栈弹出到“菜单”控制器。我有一段代码应该执行此操作,但是单击“菜单”时,应用程序崩溃。
崩溃的原因:“试图弹出到不存在的视图控制器。”
这是我的代码的一部分:
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
// 0 = menu
if indexPath.row == 0 {
let vcName = identities[indexPath.row]
let viewController = storyboard?.instantiateViewController(withIdentifier: vcName)
let _ = navigationController?.popToViewController(viewController!, animated: true)
} else {
let vcName = identities[indexPath.row]
let viewController = storyboard?.instantiateViewController(withIdentifier: vcName)
self.navigationController?.pushViewController(viewController!, animated: true)
}
}
Run Code Online (Sandbox Code Playgroud)