Dar*_*ell 4 iphone uiviewcontroller ios ios7
我在iOS 7中遇到的问题并未出现在iOS 6中.
我有一个导航控制器,显示另一个导航控制器来添加员工.第二个控制器以模态方式呈现.当我用"取消"或"完成"按钮关闭第二个控制器时,我收到错误.这是错误:
QuickSchedule [880:60b]警告:在演示或解雇过程中尝试从视图控制器中解除!
我正在使用unwind segue并使用以下相关代码从第一个控制器中解除.
这是在ScheduleViewController.m(我的主控制器窗口)
- (IBAction)done:(UIStoryboardSegue *)segue
{
if ([[segue identifier] isEqualToString:@"DoneEditing"]) {
[[MyManager sharedManager] saveChanges];
[self dismissViewControllerAnimated:YES completion:NULL];
}
}
Run Code Online (Sandbox Code Playgroud)
连接检查器中"完成"按钮的连接只是"动作 - > [展开完成:]"
在升级到Xcode 5之前我没有错误.这一切都是在将Xcode和我的故事板升级到iOS 7之后开始的.
我在我的应用程序中的不同位置得到相同的错误,但同样,它是一个模态呈现的视图控制器.
我以模态方式从EmployeeViewController转到AddEmployeeViewController.当我从AddEmployeeViewController返回时,我再次收到错误.
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];
}
}
Run Code Online (Sandbox Code Playgroud)
这是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;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我还在学习,我在网上找了几个小时,但找不到答案.我已经尝试将"保存代码"放在完成块中.我把它放回去并尝试在完成块参数中使用nil而不是NULL.正如你所看到的,我在一个完成块参数的一个位置是零,而在另一个位置是NULL.无论如何,错误不断出现.
一切都是功能,我只是将此错误记录到控制台.任何帮助是极大的赞赏.
注意:常规推送导航控制器不会出现此错误.这只是在解雇模态呈现的视图控制器时发生的.
我很惊讶你在Xcode的早期版本中不会看到同样的问题,因为我认为你的问题是调用dismissViewControllerAnimated:completion:在"done"方法中.这应该是iOS 6中的一个问题.unwind segue会为你解雇,所以你不应该自己调用这个方法.尝试将其评论出来,看看是否可以解决问题.
我在iOS 7中也遇到了同样的问题.
我的问题是调用方法上的UI(如显示UIAlertView等)viewWillAppear:.这是非常错误的,因为当一个视图被解雇时,另一个视图出现,因此两个UI方法都被调用.
我已将方法移至viewDidAppear:方法,问题已修复.
| 归档时间: |
|
| 查看次数: |
16804 次 |
| 最近记录: |