简体   繁体   English

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

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

I get the following error after I change the rootViewControler of my UIWindow. 更改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'

The strange thing is, it only occurs if I have a line in my code which will never be executed at this time. 奇怪的是,仅当我的代码中有一行当前不会执行时,它才会发生。

-(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;
                        }];
    }
}

} }

I search the whole internet but I found nothing about +[NSNotificationCenter dictationViewClass] or what this can be. 我搜索了整个互联网,但没有发现关于+ [NSNotificationCenter dictationViewClass]或可能的内容。

EDIT: I notice now, it only happens if I change the rootViewController in a transition, if I do it directly no error happens. 编辑:我现在注意到,仅当我在转换中更改rootViewController时,它才会发生,如果我直接执行它,则不会发生任何错误。

Your Error Log 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 您的错误日志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

You are calling wrong method . 您正在调用错误的方法。 dictationViewClass does not exist in ios. dictationViewClass在ios中不存在。 It's Simply mean you are trying to call a methods which is not exist for Corresponding Class ( NSNotificationCenter ). 这仅表示您正在尝试调用对应类( NSNotificationCenter )不存在的方法。 You should Change set Notification as below 您应该如下更改设置通知

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

I hope It'll be helpful to You. 希望对您有帮助。

unrecognized selector sent to class means that there is no such method defined for this class. 发送给类的无法识别的选择器意味着没有为此类定义此类方法。 Try: 尝试:

  1. Delete the line and try if it works. 删除该行,然后尝试是否行得通。
  2. Look for a category withn your sources if it contains this method 如果您的来源包含此方法,则查找该类别
  3. Write your own blank method with the same name 用相同的名称编写自己的空白方法
  4. Try to figure ouy what this method meant to do and implement it 尝试弄清楚这种方法的含义并实现它

Its not a real answer on this but the same error happens on different actions again regardless of an animation. 这不是一个真正的答案,但是无论动画如何,相同的错误都会再次发生在不同的动作上。 The problem seems to be the change of the rootviewcontroller, I replace that with a hidden tabbarcontroller and switch between the tabs and the problem is gone. 问题似乎是rootviewcontroller的更改,我将其替换为隐藏的tabbarcontroller,然后在选项卡之间进行切换,问题就消失了。

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

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