アスタの管理画面に行って、アプリを登録しましょう。




続いてXCodeを起動して、
プロジェクトにframeworkを追加しましょう。





これで追加出来ました。
続いて新規ファイルを作成しましょう。
下記の4つのファイルをiOSフォルダの直下に作成してください。

IOSSettingsはアイコン型広告のMrdIconLoaderを格納して
色んな所から呼び出すためのファイルです。
#import <Foundation/Foundation.h>
#import <MrdIconSDK/MrdIconSDK.h>
@interface IOSSettings : NSObject {
MrdIconLoader* _iconloader;
}
+(IOSSettings*) sharedSettings;
@property (nonatomic, retain) MrdIconLoader* iconLoader;
@end
#import "IOSSettings.h"
@implementation IOSSettings
static IOSSettings* g_gameSettings = nil;
+(IOSSettings*) sharedSettings
{
if (!g_gameSettings)
{
g_gameSettings = [[IOSSettings alloc] init];
}
return g_gameSettings;
}
@end
#import "UIKit/UIKit.h"
@interface IconAdViewController : UIViewController {
}
@end
#import "IconAdViewController.h"
#import <MrdIconSDK/MrdIconSDK.h>
#import "IOSSettings.h"
#define IF_NO_ARC(x) {x}
@interface IconAdViewController()
@property (nonatomic, retain) MrdIconLoader* iconLoader;
@end
@interface IconAdViewController(MrdIconLoaderDelegate)<MrdIconLoaderDelegate>
@end
@implementation IconAdViewController
@synthesize iconLoader = _iconLoader;
- (id)init
{
self = [super init];
if (self != nil) {
MrdIconLoader* iconLoader = [[MrdIconLoader alloc]init];
self.iconLoader = iconLoader;
iconLoader.delegate = self;
IF_NO_ARC([iconLoader release];)
const CGFloat viewHeight = kMrdIconCell_DefaultViewSize.height;
// The array of points used as origin of icon frame
CGRect frame = [[UIScreen mainScreen] applicationFrame];
/*
// 横一列上に表示する場合
CGPoint origins[] = {
{0, 0},
{80, 0},
{80*2, 0},
{80*3, 0},
};
*/
// 横一列下に表示する場合
CGPoint origins[] = {
{0, frame.size.height-viewHeight},
{80, frame.size.height-viewHeight},
{80*2, frame.size.height-viewHeight},
{80*3, frame.size.height-viewHeight},
};
// addSubviewしていきます
for (int i=0; i < 4; i++)
{
CGRect frame;
frame.origin = origins[i];
frame.size = kMrdIconCell_DefaultViewSize;
MrdIconCell* iconCell = [[MrdIconCell alloc]initWithFrame:frame];
[iconLoader addIconCell:iconCell];
[self.view addSubview:iconCell];
IF_NO_ARC([iconCell release];)
}
}
// アイコン型広告のローダーを保持させておく
[IOSSettings sharedSettings].iconLoader = _iconLoader;
return self;
}
@end
////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
@implementation IconAdViewController(MrdIconLoaderDelegate)
- (void)loader:(MrdIconLoader*)loader didReceiveContentForCells:(NSArray *)cells
{
}
- (void)loader:(MrdIconLoader*)loader didFailToLoadContentForCells:(NSArray*)cells
{
}
- (BOOL)loader:(MrdIconLoader*)loader willHandleTapOnCell:(MrdIconCell*)aCell
{
return YES;
}
- (void)loader:(MrdIconLoader*)loader willOpenURL:(NSURL*)url cell:(MrdIconCell*)aCell
{
}
@end
AppControllerで初期化処理を行います
@class RootViewController;
@class IconAdViewController;
@interface AppController : NSObject <UIAccelerometerDelegate, UIAlertViewDelegate, UITextFieldDelegate,UIApplicationDelegate> {
UIWindow *window;
RootViewController *viewController;
IconAdViewController *iconAdView;
}
@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) RootViewController *viewController;
@end
#import "IconAdViewController.h"
#import "IOSSettings.h"
// 取得したアイコン型広告のID
#define kMEDIA_CODE @"idxxxxxxxxx"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]
pixelFormat: kEAGLColorFormatRGBA8
depthFormat: GL_DEPTH_COMPONENT16
preserveBackbuffer: NO
sharegroup: nil
multiSampling: NO
numberOfSamples:0 ];
// Use RootViewController manage EAGLView
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
viewController.wantsFullScreenLayout = YES;
viewController.view = __glView;
// Set RootViewController to window
if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
{
// warning: addSubView doesn't work on iOS6
[window addSubview: viewController.view];
}
else
{
// use this method on ios6
[window setRootViewController:viewController];
}
// アイコン型広告初期化
iconAdView = [[IconAdViewController alloc] init];
[viewController.view addSubview: iconAdView.view];
// アイコン表示スタート
[[IOSSettings sharedSettings].iconLoader startLoadWithMediaCode: kMEDIA_CODE];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];
cocos2d::CCApplication::sharedApplication()->run();
return YES;
}
正しく設定出来ていればこのように表示されると思います!

スポンサーサイト