简体   繁体   English

UIBarButtonItem 导致应用程序崩溃

[英]UIBarButtonItem causes app to crash

I'm learning to code in Objective-C by developing a simple app.我正在通过开发一个简单的应用程序学习在 Objective-C 中编码。 I'm using a UISplitViewController which has UIBarButtonItem .我使用的是UISplitViewController具有UIBarButtonItem When you tap an item on the left UINavigationController , shows up on the right one.当您点击左侧UINavigationController上的一项时,会显示在右侧。 This right one has a button inside which takes you to a web site, controlled by a browser controller;这个右边有一个按钮,可以将您带到一个由浏览器控制器控制的网站; when tapped, up left on the UIBar appears a button to go back/to the previous view.点击时,UIBar 的左上方会出现一个按钮,用于返回/返回上一个视图。

The problem is that when I tap this button, the app crashes and Xcode tells me the problem is the method viewWillDisappear in the browser controller.问题是当我点击这个按钮时,应用程序崩溃了,Xcode 告诉我问题是浏览器控制器中的viewWillDisappear方法。 I've checked it up and down dozen times and can't find the error.我已经上下检查了十几次,但找不到错误。

代码和错误

Change改变

[self viewWillDisappear : animated];

to

[super viewWillDisappear : animated];

Your way creates an infinite recursion - method calling itself - visible also in Thread 1 call stack.您的方式创建了无限递归 - 方法调用自身 - 在线程 1 调用堆栈中也可见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM