我运行了此代码here,它运行良好。
但是,尝试将其添加到我的项目时遇到了问题。
类(class)结束后,YouTubeHelper 调用showAuthenticationViewController:

– (void)showAuthenticationViewController:(UIViewController *)authView {
    [self.navigationController presentViewController:authView animated:NO completion:nil];
}

在GTMOAuth2ViewControllerTouch.m内部,我在exc_bad_access上的loadView内部获得了[super loadView],如下所示:
– (void)loadView {
    NSString *nibPath = nil;
    NSBundle *nibBundle = [self nibBundle];
    if (nibBundle == nil) {
        nibBundle = [NSBundle mainBundle];
    }
    NSString *nibName = self.nibName;
    if (nibName != nil) {
        nibPath = [nibBundle pathForResource:nibName ofType:@”nib”];
    }
    if (nibPath != nil && [[NSFileManager defaultManager] fileExistsAtPath:nibPath]) {
        [super loadView]; <<<< exc_bad_access here!
    } else {
        // One of the requirements of loadView is that a valid view object is set to
        // self.view upon completion. Otherwise, subclasses that attempt to
        // access self.view after calling [super loadView] will enter an infinite
        // loop due to the fact that UIViewController's -view accessor calls
        // loadView when self.view is nil.
        self.view = [[[UIView alloc] init] autorelease];

#if DEBUG
        NSLog(@"missing %@.nib", nibName);
#endif
    }
}

知道为什么会这样以及如何解决吗?

谢谢!

最佳答案

您永远不要在子类中调用[super loadView];。从您的实现中删除该行。



引用:UIViewController Class Reference

关于ios - iOS YouTube认证EXC_BAD_EXCEPTION,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32976889/

10-11 15:07