简体   繁体   中英

error after change rootviewcontroller +[NSNotificationCenter dictationViewClass]

I get the following error after I change the rootViewControler of my UIWindow.

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.

EDIT: I notice now, it only happens if I change the rootViewController in a transition, if I do it directly no error happens.

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

You are calling wrong method . dictationViewClass does not exist in ios. It's Simply mean you are trying to call a methods which is not exist for Corresponding Class ( 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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