本文介绍了不断收到“对 <ViewController> 的开始/结束外观转换的不平衡调用""错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个几乎运行完美的应用程序.以下是我的应用的结构:

I have an app that is almost running perfectly. Here is how my app is structured:

故事板上共有 6 个视图控制器.前 3 个 View Controller 是最重要的.初始视图控制器具有登录"和注册"按钮.登录"按钮模态显示登录视图控制器,注册"按钮模态显示注册视图控制器.

6 total View Controllers on the storyboard. The first 3 View Controllers are the most important. The initial View Controller has buttons to "Login" and "Signup". The "Login" button modally presents a Login View Controller and the "Signup" button modally presents a Signup View Controller.

注册视图控制器有 3 个字段,分别是用户名、密码和电子邮件,然后是一个提交"按钮.提交按钮将数据提交到我的网络服务器,如果所有内容都提交成功,它会自行调用performSegueWithIdentifier"方法.

The Signup View Controller has 3 fields for username, password, and email and then a "submit" button. The submit button submits the data to my web server and if everything submits successfully it calls the "performSegueWithIdentifier" method on itself.

声明如下:

[self performSegueWithIdentifier:@"superSegue" sender:self];

今晚我花了 2 个小时试图让上述方法调用起作用,它终于起作用了.为了让它工作,我必须在故事板上选择我的注册视图控制器,然后转到编辑器 > 嵌入 > 导航控制器(如果我没记错的话,我必须这样做,因为注册视图控制器是以模态方式呈现的).然后我从我的注册视图控制器的提交按钮拖到我想要推送到的视图控制器并选择推送,然后输入一个标识符名称.

I spent 2 hours tonight trying to get the above method call to work and it finally does work. To get it to work, I had to select my Signup View Controller on the storyboard and go to Editor > Embed In > Navigation Controller (If I remember correctly I had to do this because the signup view controller is presented modally). I then dragged from my Signup View Controller's submit button to the View Controller I want to push to and selected Push and then typed in an identifier name.

无论如何,在我尝试使用我们使用方法调用推送到的视图控制器上的后退按钮之前,上述所有操作都非常好.如果我点击后退按钮,它将进入 90% 的黑屏,顶部有一个空白导航栏和一个后退按钮,当然该后退按钮也没有任何作用.

Anyways, all of the above works perfectly fine until I try to use the back button on the View Controller that we pushed to using the method call. If I tap the back button, it goes to a 90% black screen with a blank nav bar at the top with a back button and of course that back button does nothing as well.

这是我在控制台中遇到的错误:

This is the error that I get in the console:

Unbalanced calls to begin/end appearance transitions for <VerificationViewController: 0x14ed1bb0>

验证视图控制器是注册视图控制器通过 performSegueWithIdentifier 方法推送到的视图控制器.

Verification View Controller is the View Controller that the Signup View Controller pushes to via the performSegueWithIdentifier method.

有谁知道我该如何解决这个错误?

Does anyone know how I can fix this error?

我在下面附上了我的故事板在 xcode 中的截图.我已经编写了一个视图控制器,但还没有连接,无论如何都不应该有所作为,因此您可以忽略 Login VC 右侧的视图控制器.

I have included a screenshot below of what my storyboard looks like in xcode. There is a view controller that I have coded but not connected yet and shouldn't make a difference anyways so you can ignore the View Controller to the right of the Login VC.

推荐答案

今天早上我在另一个 stackoverflow 问题中找到了答案.可以在这里找到答案.

I found the answer this morning in another stackoverflow question. The answer can be found here.

当我最初设置 Push Segue 时,我单击并拖动按钮,并且还在该按钮的 IBAction 方法实现中调用 performSegueWIthIdentifier 方法.这导致在按钮按下时执行 2 个相同的 push segues.我只是将我的方法调用留在了 IBAction 中,删除了旧的 push segue,并创建了一个新的 push segue,只是这次我点击并从整个 View Controller 中拖动而不是它的按钮.

When I had originally setup the Push Segue, I clicked on and dragged from a button, and was also calling the performSegueWIthIdentifier method inside that button's IBAction method implementation. This was causing 2 identical push segues to be executed on the button press. I just left my method call in the IBAction, deleted the old push segue, and created a new push segue only this time I clicked on and dragged from the entire View Controller instead of it's button.

这篇关于不断收到“对 &lt;ViewController&gt; 的开始/结束外观转换的不平衡调用""错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 12:04