1

I have an adwhirlview in my navigation controller at the "2nd page" so it's root -> adwhirlpage.

The showing of the banner goes great, but if I pop the navigationcontroller back to root, after 20 secs or so, the debugger gives me an error:

 -[__NSCFTimer viewControllerForPresentingModalView]: unrecognized selector sent to instance 0xa8a5cc0
2012-10-22 16:22:49.173 Tap Chap backup[1376:1be03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFTimer viewControllerForPresentingModalView]: unrecognized selector sent to instance 0xa8a5cc0'
*** First throw call stack:
(0x1ddb022 0x2e4ccd6 0x1ddccbd 0x1d41ed0 0x1d41cb2 0xe806 0x1d172 0x1c63e 0x1d331 0x1731eb6 0x1daf936 0x1daf3d7 0x1d12790 0x1d11d84 0x1d11c9b 0x23947d8 0x239488a 0xdf5626 0x2dea 0x2d35)
terminate called throwing an exception(lldb) 

My code is as follows:

-(IBAction)backMainMenu
{
    [self.navigationController popViewControllerAnimated:YES];
    [self.adwhirlView1 removeFromSuperview];
}

- (void)viewDidLoad
{
    [self showBanner];
}

-(UIViewController *)viewControllerForPresentingModalView
{
    return self.navigationController;
}

-(NSString *)adWhirlApplicationKey 
{
    return @"my key";
}

-(void)showBanner
{
    self.adwhirlView1  = [AdWhirlView requestAdWhirlViewWithDelegate:self];

    //  adwhirlView1.bounds = CGRectMake(0.0, 0.0, 480, 50);

    [self.navigationController.view addSubview:self.adwhirlView1];

}

-(void)adWhirlDidReceiveAd:(AdWhirlView *) adWhirlView 
{
    [UIView beginAnimations:@"AdWhirlDelegate.adWhirlDidReceiveAd:" context:nil];

    [UIView setAnimationDuration:0.7];
    CGSize adSize = [adwhirlView1 actualAdSize];
    CGRect newFrame = adwhirlView1.frame;
    newFrame.size = adSize;
    newFrame.origin.x = (self.view.bounds.size.width - adSize.width)/ 2;
    adwhirlView1.frame = newFrame;

    CGAffineTransform makeLandscape = CGAffineTransformMakeRotation(degreesToRadians(0));
    makeLandscape = CGAffineTransformTranslate(makeLandscape, -480/2 + 48/2, 320/2 - 48/2 - 12);
    makeLandscape = CGAffineTransformScale(makeLandscape, 480.0/320, 480.0/320);
    adwhirlView1.transform = makeLandscape;

    adwhirlView1.frame = CGRectMake(0, 250, 480, 100);

    [UIView commitAnimations];
}

I hope you guys can help me with removing this error, which thus gives the already placed error.

Cheers

coderjoe
  • 137
  • 2
  • 16

2 Answers2

0

Your calling a UINavigationController method on an NSTimer. That will not work.

-[__NSCFTimer viewControllerForPresentingModalView]: unrecognized selector sent to instance 0xa8a5cc0

deleted_user
  • 3,817
  • 1
  • 18
  • 27
  • yeah, but i dont have a timer in my root controller, so i think adwhirl is still calling at my root, but i only want it to respond to the 2nd page. That's the odd thing – coderjoe Oct 22 '12 at 18:13
  • Sorry I dont know adwhirl - but the error message is pretty clear, something is getting passed in where it shouldnt. – deleted_user Oct 22 '12 at 18:16
  • I know, but how can i stop the adwhirlbanner calling to the root after it has been popped from the second page? – coderjoe Oct 22 '12 at 18:21
0

Do you still get the error message if you nil out self.adwhirlView1's delegate right before you remove it from the superview?

RajPara
  • 2,281
  • 1
  • 16
  • 9
  • No, but an other error: `if ([adWhirlDelegate respondsToSelector:@selector(adWhirlTestMode)] && [adWhirlDelegate adWhirlTestMode]) { request.testing = YES; } ` gives an exc_bad_access – coderjoe Oct 23 '12 at 15:26
  • Hmm what if instead of calling removeFromSuperView, you clean up the adWhirlView by calling self.adWhirlView.delegate = nil and self.adwhirlView = nil? – RajPara Oct 23 '12 at 17:44
  • Can you check to make sure your initial AdWhirlView isn't leaking when you pop the VC? You can probably look at this in Leaks. – RajPara Oct 24 '12 at 14:00