0

我试图在 iOS6 中关闭表单模式视图。它在 iOS5 中完全正常,但在 6 中失败。(项目在两者中都使用 ARC)。

这是失败时的堆栈:

#0  0x0175a267 in objc_msgSend_stret ()
#1  0x006d55bd in -[UIView(Geometry) bounds] ()
#2  0x006cc707 in -[UIWindow _updateCurrentTintView] ()
#3  0x0075117b in -[UITransitionView transition:fromView:toView:removeFromView:] ()
#4  0x0097df44 in __91-[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:]_block_invoke_0236 ()
#5  0x0097d4eb in -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] ()
#6  0x0077ba11 in -[UIViewController _dismissViewControllerWithTransition:from:completion:] ()
#7  0x0077aecd in -[UIViewController dismissViewControllerWithTransition:completion:] ()
#8  0x0077bbdb in -[UIViewController dismissViewControllerAnimated:completion:] ()
#9  0x00056a50 in -[HandDeviceToAssessorViewController dismiss:] at <directory of file>

视图控制器是这样创建的:

+ (HandDeviceToAssessorViewController *)handDeviceToAssessorWithWellDoneView
{
    static dispatch_once_t pred;
    static HandDeviceToAssessorViewController *viewController = nil;

    dispatch_once(&pred, ^(void)
                  {
                      viewController = [[HandDeviceToAssessorViewController alloc] initWithNibName:@"WellDoneHandDeviceToAssessorView" bundle:[NSBundle mainBundle]];
                  });

    viewController.modalPresentationStyle = UIModalPresentationFormSheet;
    return viewController;
}

并用代码显示:

HandDeviceToAssessorViewController *handBackModal = [HandDeviceToAssessorViewController handDeviceToAssessorWithWellDoneView];
    handBackModal.delegate = self;
    [self presentViewController:handBackModal animated:YES completion:nil];

视图控制器被解雇了。

- (IBAction)dismiss:(id)sender
{
    if ([self.delegate respondsToSelector:@selector(viewWillClose)])
    {
        [self.delegate viewWillClose];
    }

    [self.presentingViewController dismissViewControllerAnimated:YES completion:^(void)
    {
        if ([self.delegate respondsToSelector:@selector(viewDidClose)])
        {
            [self.delegate viewDidClose];
            self.delegate = nil;
        }
    }];
}

我怀疑/希望这不是 iOS6 中的错误。关于如何解决这个问题的任何想法?

4

1 回答 1

1

尝试将dismissViewController消息发送到self而不是self.presentingViewController. 它将被转发到正确的视图控制器。

希望这可以帮助!

于 2012-12-17T10:02:59.480 回答