NKBanner
Overview
NKBanner class is used to add advertisement to iPhone apps running iOS 4.0 and newer (iAd).
init(x, y, isHorizontal)
initializes advertisement view with given coordinates, multiple calls to this method change only position without reinitializing the control (hidden by default). isHorizontal parameter can take values "yes"/"no" or 1/0 which is used to specify orientation for the banner requested.
show()
shows initialized banner view (banners are initially hidden)
hide()
hides advertisement view
Callbacks:
All callbacks have to be implemented on the page where specific NKBanner was created, they will be called automatically.
bannerViewDidLoadAd()
called when iAd banner is loaded and ready to be shown. Usually only in this method you need to show the ad. If you show the banner before then application can be rejected in the App Store.
didFailToReceiveAdWithError(error)
called when error happened during iAd retrieving. This method must be implemented and if case error happened and invoked error must be processed and appropriate actions taken otherwise the application may be rejected in the App Store.
bannerActionShouldBeginWillLeaveApplication(isLeaving)
this callback is called when iAd banner was clicked. isLeaving parameter can be either "YES" or "NO" means either ad needs to quit the application to proceed or ad can show the information without closing the application.
bannerViewActionDidFinish()
called when banner action view has been dismissed and the application is active again.
Example:
banner = new NKBanner;
banner.init(0, 0, "no"); // load portrait mode ad
function bannerViewDidLoadAd()
{
NKLog("We have the banner loaded, now we can show it");
NKLog("After creating we still can reposition it by calling init function");
banner.show();
}
function didFailToReceiveAdWithError(error)
{
NKLog(error);
}
function bannerActionShouldBeginWillLeaveApplication(isLeaving)
{
if (isLeaving == "YES")
{
NKLog("iad quits this app to proceed");
}
else
{
NKLog("iad clicked, but the app is still remains launched");
}
}
function bannerViewActionDidFinish()
{
NKLog("Banner action is finished and now we returned back to the our application");
}

