iOS 7错误警告:尝试从视图控制器中解除< UINavigationController:0x1568db40>正在进行演示或解雇 [英] iOS 7 error Warning: Attempt to dismiss from view controller <UINavigationController: 0x1568db40> while a presentation or dismiss is in progress
问题描述
我在iOS 7中遇到的问题没有出现在iOS 6中。
I have issue in iOS 7 that does not appear in iOS 6.
我有一个导航控制器,显示另一个导航控制器来添加员工。第二个控制器以模态方式呈现。当我用取消或完成按钮关闭第二个控制器时,出现错误。这是错误:
I have a navigation controller that is displaying another navigation controller to add an employee. This second controller is being presented modally. When I dismiss the second controller either with a "Cancel" or "Done" button, I get an error. Here is the error:
QuickSchedule [880:60b]警告:在演示文稿$ b时尝试从视图
控制器中解除$ b或解雇正在进行中!
QuickSchedule[880:60b] Warning: Attempt to dismiss from view controller while a presentation or dismiss is in progress!
我正在使用unwind segue并使用以下相关代码从第一个控制器中解除。
I am using an unwind segue and dismissing from the first controller using the following relevant code.
这是在ScheduleViewController.m(我的主控制器窗口)
This is in ScheduleViewController.m (My main controller window)
- (IBAction)done:(UIStoryboardSegue *)segue
{
if ([[segue identifier] isEqualToString:@"DoneEditing"]) {
[[MyManager sharedManager] saveChanges];
[self dismissViewControllerAnimated:YES completion:NULL];
}
}
连接检查器中完成的连接按钮只是
动作 - > [展开完成:]
The connection in the connection inspector for the "Done" button is simply "action -> [unwind done:]"
我在升级到Xcode 5之前没有错误。这一切都是在升级Xcode和我之后开始的故事板到iOS 7。
I had no errors before upgrading to Xcode 5. This all started after upgrading Xcode and my storyboard to iOS 7.
我在我的应用程序中的不同位置得到相同的错误,但同样,它是一个模态呈现的视图控制器。
I am getting same error in different spot in my app, but again, it's with a modally presented view controller.
我从EmployeeViewController模态地转到AddEmployeeViewController。当我从AddEmployeeViewController返回时,我再次收到错误。
I go from EmployeeViewController to AddEmployeeViewController modally. I get the error again when I return from AddEmployeeViewController.
EmployeeViewController.m
EmployeeViewController.m
- (IBAction)done:(UIStoryboardSegue *)segue
{
if ([[segue identifier] isEqualToString:@"ReturnInput"]) {
AddEmployeeViewController *addController = [segue sourceViewController];
if (addController.employee) {
[[MyManager sharedManager] saveChanges];
[[self tableView] reloadData];
}
if (![self.presentedViewController isBeingDismissed]) {
[self dismissViewControllerAnimated:YES completion:nil];
}
}
}
- (IBAction)cancel:(UIStoryboardSegue *)segue
{
if ([[segue identifier] isEqualToString:@"CancelInput"]) {
[self dismissViewControllerAnimated:YES completion:NULL];
}
}
这是AddEmployeeViewController.m
Here is AddEmployeeViewController.m
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"ReturnInput"]) {
if ([self.firstNameField.text length] || [self.lastNameField.text length]) {
Employee *newEmployee = [[MyManager sharedManager] createEmployeeWithFirstName:self.firstNameField.text andLastName:self.lastNameField.text];
[[MyManager sharedManager] addEmployeeToList:newEmployee];
self.employee = newEmployee;
}
}
}
我还在学习,我在网上找了几个小时,找不到答案。我已经尝试将保存代码放在完成块中。我把它放回去并尝试在完成块参数中使用nil而不是NULL。正如你所看到的,我在一个完成块参数的一个位置是零,而在另一个参数上是NULL。无论如何,错误一直在出现。
I am still learning, and I have looked for hours online and cannot find an answer to this. I have tried putting the "saving code" in a completion block. I put it back and tried using nil instead of NULL in the completion block argument. As you can see, I have nil in one spot on a completion block argument and NULL on another. No matter what, the error keeps appearing.
一切都是功能,我只是将此错误记录到控制台。非常感谢任何帮助。
Everything works as far a functionality, I just get this error logged to the console. Any help is greatly appreciated.
注意:
我不会通过常规推送导航控制器得到此错误。这只是在解雇模态呈现的视图控制器时发生的。
Note: I do not get this error with regular pushed navigation controllers. This is only happening on dismissing modally presented view controllers.
推荐答案
我很惊讶你不会看到同样的问题以前版本的Xcode,因为我认为你的问题是调用dismissViewControllerAnimated:completion:在done方法中。这应该是iOS 6中的一个问题。 unwind segue会为你解雇,所以你不应该自己调用这个方法。尝试将其评论出来,看看是否能解决问题。
I'm surprised that you wouldn't see this same problem in previous versions of Xcode, because I think your problem is calling dismissViewControllerAnimated:completion: in the "done" method. This should have been a problem in iOS 6 as well. The unwind segue does the dismissal for you, so you shouldn't call this method yourself. Try commenting it out, and see if that fixes the problem.
这篇关于iOS 7错误警告:尝试从视图控制器中解除< UINavigationController:0x1568db40>正在进行演示或解雇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!