0

I am getting the following error message...

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[YTPlayerView playerView]: unrecognized selector sent to instance 0x7fd77bd41f80'

and here is my code..

- (void)applicationDidEnterBackground:(NSNotification *)notification
{   
    [_playerView performSelector:@selector(playerView) withObject:nil afterDelay:0.1];

}

- (IBAction)didTapPlayPause:(id)sender {
    self.btnPlayPause.selected = !self.btnPlayPause.selected;
    if (self.btnPlayPause.selected)
    {
        self.title=self.strngvideotitle;
        self.playerView=[[YTPlayerView alloc]initWithFrame:CGRectMake(0,0,375,290)];
        [self.playerView loadWithVideoId:self.strngvideoId];
        [self.view addSubview:_playerView];

      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil];

   }
Imad Ali
  • 3,261
  • 1
  • 25
  • 33
Roby
  • 3
  • 5

1 Answers1

0

Your code fails at this statement

[_playerView performSelector:@selector(playerView) withObject:nil afterDelay:0.1];

The statement expects that your _playerView object will call the method playerView after a delay of 0.1 seconds. But the class YTPlayerView does not have a method called playerView. You might want to check the actual method name and replace it in the selector name.

lostInTransit
  • 70,519
  • 61
  • 198
  • 274
  • ya may be correct, allocate your `self.playerView=[[YTPlayerView alloc]` in didfinish launch o – Anbu.Karthik May 22 '17 at 06:22
  • That is not the point. The problem is that there is no method called `playerView`. The method would be called something else like `playVideo` maybe (https://github.com/youtube/youtube-ios-player-helper/blob/master/Classes/YTPlayerView.h#L247) – lostInTransit May 22 '17 at 06:27