添加:(id)sender之后,我从该例程中崩溃,因此我可以确定哪个按钮调用了它。当设置为普通的旧版toggleView3时,它可以完美运行。当detailView切换回docView时发生崩溃。
'NSInvalidArgumentException', reason: '*** -[RootViewController toggleView3]: unrecognized selector sent to instance 0x524a00'2009-04-07 12:29:44.421 eTarot[11405:20b] Stack:

-(IBAction)toggleView3:(id)sender{


    if (detailViewController == nil) {
        [self loadDetailViewController];
    }

    UIView *docView = docViewController.view;
    UIView *detailView = detailViewController.view;

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1];
    [UIView setAnimationTransition:([docView superview] ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromLeft) forView:self.view cache:YES];

    if ([docView superview] != nil) {
        [detailViewController viewWillAppear:YES];
        [docViewController viewWillDisappear:YES];
        [docView removeFromSuperview];

        [self.view addSubview:detailView];
        [self.view insertSubview:detailNavigationBar aboveSubview:detailView];
        [docViewController viewDidDisappear:YES];
        [detailViewController viewDidAppear:YES];

    } else {
        [docViewController viewWillAppear:YES];
        [detailViewController viewWillDisappear:YES];
        [detailView removeFromSuperview];
        [detailNavigationBar removeFromSuperview];
        [self.view addSubview:docView];
        [detailViewController viewDidDisappear:YES];
        [docViewController viewDidAppear:YES];
    }
    [UIView commitAnimations];
}

最佳答案

你发送一个 View 中的邮件toggleView3时选择的正确名称是toggleView3: - 也就是说,用冒号和论证。它们看起来可能与您相似,但是与Objective-C完全不同。

关于iphone - NSInvalidArgumentException,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/726727/

10-12 04:34