繁体   English   中英

更改rootviewcontroller + [NSNotificationCenter dictationViewClass]后出现错误

[英]error after change rootviewcontroller +[NSNotificationCenter dictationViewClass]

更改UIWindow的rootViewControler后,出现以下错误。

2012-10-16 15:12:35.653 repdocApp[22898:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSNotificationCenter dictationViewClass]: unrecognized selector sent to class 0x1d63914'

奇怪的是,仅当我的代码中有一行当前不会执行时,它才会发生。

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{   
    AppDelegate *app = (AppDelegate *) [[UIApplication sharedApplication] delegate];
    OverviewModel *model = [self.dataArray objectAtIndex:indexPath.row];

if (model.modelType == ModelTypeCatalog)
{
     NSLog(@"HERE");
    if (app.window.rootViewController == app.catalogViewController)
    {
        return;
    }
    // with this return no error but this branch is never executed
    // return;
    [UIView transitionFromView:app.window.rootViewController.view
                        toView:app.catalogViewController.view
                      duration:0.45f
                       options:UIViewAnimationOptionTransitionCrossDissolve
                    completion:^(BOOL finished){
                        app.window.rootViewController = app.catalogViewController;
                    }];
}
else
{
    if (app.window.rootViewController == app.catalogViewController)
    {
        [app.navigationPopoverController dismissPopoverAnimated:NO];
        [UIView transitionFromView:app.window.rootViewController.view
                            toView:app.splitViewController.view
                          duration:0.45f
                           options:UIViewAnimationOptionTransitionCrossDissolve
                        completion:^(BOOL finished){
                            app.window.rootViewController = app.splitViewController;
                        }];
    }
}

}

我搜索了整个互联网,但没有发现关于+ [NSNotificationCenter dictationViewClass]或可能的内容。

编辑:我现在注意到,仅当我在转换中更改rootViewController时,它才会发生,如果我直接执行它,则不会发生任何错误。

您的错误日志is 2012-10-16 15:12:35.653 repdocApp[22898:c07] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSNotificationCenter dictationViewClass]: unrecognized selector sent to class 0x1d63914

您正在调用错误的方法。 dictationViewClass在ios中不存在。 这仅表示您正在尝试调用对应类( NSNotificationCenter )不存在的方法。 您应该如下更改设置通知

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(yourMethodWantToExcute:) name:@"NSNotificationName" object:nil];

希望对您有帮助。

发送给类的无法识别的选择器意味着没有为此类定义此类方法。 尝试:

  1. 删除该行,然后尝试是否行得通。
  2. 如果您的来源包含此方法,则查找该类别
  3. 用相同的名称编写自己的空白方法
  4. 尝试弄清楚这种方法的含义并实现它

这不是一个真正的答案,但是无论动画如何,相同的错误都会再次发生在不同的动作上。 问题似乎是rootviewcontroller的更改,我将其替换为隐藏的tabbarcontroller,然后在选项卡之间进行切换,问题就消失了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM