-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAdamMobileViewController.m
More file actions
160 lines (115 loc) · 4.75 KB
/
Copy pathAdamMobileViewController.m
File metadata and controls
160 lines (115 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
//
// AdamMobileViewController.m
// EventsList
//
// Created by Geunwon,Mo on 11. 9. 2..
// Copyright (c) 2011년 lomohome.com. All rights reserved.
//
#import "AdamMobileViewController.h"
@implementation AdamMobileViewController
@synthesize delegate,currentAdamAdView;
-(id)initWithRootViewController:(UIViewController *)_rootViewCont withCustomRootFrame:(CGRect)_cFrame;{
self = [super init];
if (self) {
//isLoaded = NO;
//광고뷰를 싱글턴에서 가져온다.
NSLog(@"initWithRootViewController aDAM ");
currentAdamAdView = [AdamAdView sharedAdView];
//위치는 광고 가져온다음 다시 조정된다. 이것은 임시 위치값.
currentAdamAdView.frame = CGRectMake(0.0, _cFrame.size.height - ADAM_HEIGHT, _cFrame.size.width, ADAM_HEIGHT); //self.view.bounds.size.width
CGRect frame = currentAdamAdView.frame;
frame.origin.y -= _rootViewCont.tabBarController.tabBar.frame.size.height;
currentAdamAdView.frame = frame;
currentAdamAdView.delegate = self;
currentAdamAdView.clientId = ADAM_CLIENT_ID;// ADAM_TEST_CLIENT_ID; //ADAM_CLIENT_ID;
currentAdamAdView.transitionStyle = AdamAdViewTransitionStyleCurl;
currentAdamAdView.tag = _AD_ADAM+100;
currentAdamAdView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
//TODO: TEST
currentAdamAdView.backgroundColor = UIColorFromRGB(0xefeff4);
if (![currentAdamAdView.superview isEqual:_rootViewCont.view]) {
[_rootViewCont.view addSubview:currentAdamAdView];
if (!currentAdamAdView.usingAutoRequest) {
[currentAdamAdView startAutoRequestAd:ADAM_REFRESH_PERIOD];
}
}
}
return self;
}
// 광고를 가져왔다. 타이머를 지정해서 광고를 일정시간마다 갱신하도록 할 수 있다.
-(void)didReceiveAd:(AdamAdView *)adView{
NSLog(@"AD@m getter success!!!");
if (delegate && [delegate respondsToSelector:@selector(adamReceiveSuccess)]){
[delegate adamReceiveSuccess];
}
}
// 광고 가져오기를 실패했다. 이전 광고가 있다면 계속 보여줄 수도 있고, 광고 view 를 해지할 수도 있다.
/**
- AdamErrorTypeNoFillAd
현재 노출 가능한 광고가 없음.
- AdamErrorTypeNoClientId
Client ID 가 설정되지 않았음.
- AdamErrorTypeTooSmallAdView
광고 뷰의 크기가 기준보다 작음.
- AdamErrorTypeInvisibleAdView
광고 뷰가 화면에 보여지지 않고 있음.
- AdamErrorTypeAlreadyUsingAutoRequest
이미 광고 자동요청 기능을 사용하고 있는 상태임.
- AdamErrorTypeTooShortRequestInterval
허용되는 최소 호출 간격보다 짧은 시간 내에 광고를 재요청 했음.
- AdamErrorTypePreviousRequestNotFinished
이전 광고 요청에 대한 처리가 아직 완료되지 않았음.
*/
-(void)didFailToReceiveAd:(AdamAdView *)adView error:(NSError *)error{
NSLog(@"AD@m getter fail!!! : %@",error.localizedDescription);
//꼬인 레이아웃 재설정
//[nc postNotificationName:@"LAYOUT_RESET" object:self userInfo:nil];
if (delegate && [delegate respondsToSelector:@selector(adamReceiveFail)]){
[delegate adamReceiveFail];
}
}
- (void)refreshAd:(NSTimer *)timer {
NSLog(@"AD@m refresh");
[currentAdamAdView requestAd];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)isADShow{
NSLog(@"광고가 보여지고 있는가?? %@",([currentAdamAdView hasAd]?@"넴":@"아뇽"));
// return [currentAdView hasAd]; // 시간상의 오류로 사용안함
// return isLoaded;
return [currentAdamAdView hasAd];
}
-(void)willOpenFullScreenAd:(AdamAdView *)adView{
NSLog(@"AD@m will open!!!");
if (delegate && [delegate respondsToSelector:@selector(adamWillOpen)]){
[delegate adamWillOpen];
}
}
-(void)didCloseFullScreenAd:(AdamAdView *)adView{
NSLog(@"AD@m did close!!!");
if (delegate && [delegate respondsToSelector:@selector(adamDidClose)]){
[delegate adamDidClose];
}
}
-(void)willResignByAd:(AdamAdView *)adView{
NSLog(@"AD@M : willResideAd : 어플이 Foreground 에서 내려갈때.");
}
- (void)willCloseFullScreenAd:(AdamAdView *)adView{
NSLog(@"AD@m will close!!!");
if (delegate && [delegate respondsToSelector:@selector(adamWillClose)]){
[delegate adamWillClose];
}
}
@end