|
Here is sample XCode that can be
used to natively serve ads using iPhone/Ipad XCode and Ban Man Pro.
This code fully supports the Ban Man Pro Zone Refresh Interval
for automatically pulling a new ad every X seconds. This
code has only been tested in Ban Man Pro 11.
In this code you must replace
<Your URL to Ban Man Pro>
with the full URL where you installed Ban Man Pro. You
must also replace ZoneID=16 and SiteID=2 with your actual ZoneID
and SiteID.
To control the placement of the
ad area on the phone's screen, modify these coordinates:
CGRectMake(0.0,20.0,300.0,60.0)
/* This code
creates the WebView and loads an Ad*/
- (BOOL)application:(UIApplication
*)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions {
UIWebView
* mywebView = [[UIWebView
alloc]
initWithFrame:CGRectMake(0.0,20.0,300.0,60.0)];
mywebView.delegate=
self;
[mywebView
loadRequest:[NSURLRequest
requestWithURL:[NSURL
URLWithString:@"http://<Your
URL to Ban Man Pro>/a.aspx?Task=Get&ZoneID=16&SiteID=2"]]];
[window
addSubview:mywebView];
[window
makeKeyAndVisible];
return
YES;
}
/* This code
controls the click behavior so the click does not open inside
the web view*/
- (BOOL)webView:(UIWebView*)mywebView
shouldStartLoadWithRequest:(NSURLRequest*)request
navigationType:(UIWebViewNavigationType)navigationType{
if
(UIWebViewNavigationTypeLinkClicked
== navigationType)
{
NSURL
*url=[request URL];
NSString
*scheme = [[url scheme]
lowercaseString];
if
([scheme isEqualToString:@"http"]
|| [scheme isEqualToString:@"https"]){
[[UIApplication
sharedApplication]
openURL:url];
return
NO;
}
else
{
return
YES;
}
}
return
YES;
}
Full documentation on the WebView Class is available on the
Apple.com web site by clicking here.
|