2

Can I add the UIBannerViewDelegate protocol to my UIViewController subclass while remaining compatible with pre-iOS 4 devices?

This is NOT a duplicate, the question is specifically related to the delegate protocol.

  • 2
    Translation: *Can I add the `UIBannerViewDelegate` protocol to my `UIViewController` subclass while remaining compatible with pre-iOS 4 devices?* – bbum Jun 27 '10 at 19:03
  • Duplicate: http://stackoverflow.com/questions/3027120/how-to-make-iphone-app-for-multiple-firmwares/3027213#3027213 – progrmr Jun 27 '10 at 19:18
  • Not Duplicate: it doesn't answer my question. This relates to the protocol as bbum says. –  Jun 27 '10 at 19:45

1 Answers1

3

If you weak-link the iAd framework, you will encounter no issues with a controller class that conforms to the ADBannerViewDelegate protocol. You will, of course, need to add the ADBannerView programmatically (if it exists on the running OS) or otherwise load a different Nib file for 3.x vs. 4.x.

Even though there is no ADBannerViewDelegate protocol in iPhone OS 3.x, I just tested and no errors are thrown for missing symbols if a class that conforms to it is loaded in that older OS.

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
  • Yeah, it works this way. You just need to check: "if (NSClassFromString(@"ADBannerView"))". See more code details here: http://iphone-dev-tips.alterplay.com/2010/07/what-ive-already-used-more-than-once.html – slatvick Jul 18 '10 at 05:46