我的应用程序导航控制器和标签栏控制器中有两个控制器。导航控制器视图不实现 adwhirl 和标签栏控制器所有选项卡所有视图都实现了 adwhirl。
@interface myview : UIViewController {
AdWhirlView *awView;
}
@property (nonatomic, retain) AdWhirlView *awView;
@implementation myview
@synthesize awView;
- (UIViewController *)viewControllerForPresentingModalView {
return self;
}
- (NSString *)adWhirlApplicationKey {
return @"Mykey";
}
-(void) viewWillAppear:(BOOL)animated{
// code for Adwhirl banner
self.awView = [AdWhirlView requestAdWhirlViewWithDelegate:self];
[self.awView setFrame:CGRectMake(0, 318, 320, 50)];
[self.view addSubview:self.awView];
}
-(void) viewWillDisappear:(BOOL)animated{
[self.awView release];
}
我已经在标签栏控制器的每个视图中编写了这段代码。当我将导航控制器切换到标签栏控制器时,Adwhirl 非常有效。但是当我将标签栏控制器切换到导航控制器时,应用程序崩溃了。
崩溃错误如下。
由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[__NSCFArray viewControllerForPresentingModalView]:无法识别的选择器发送到实例 0xfd91600”
*** Call stack at first throw:
(
0 CoreFoundation 0x018525a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x019a6313 objc_exception_throw + 44
2 CoreFoundation 0x018540bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x017c3966 ___forwarding___ + 966
4 CoreFoundation 0x017c3522 _CF_forwarding_prep_0 + 50
5 IDogEvents 0x0002e30b -[AdWhirlAdapterGoogleAdMobAds getAd] + 2075
6 IDogEvents 0x00040154 -[AdWhirlView makeAdRequest:] + 1524
7 IDogEvents 0x0003f501 -[AdWhirlView buildPrioritizedAdNetCfgsAndMakeRequest] + 1569
8 IDogEvents 0x000402ef -[AdWhirlView timerRequestFreshAd] + 255
9 Foundation 0x0095b749 __NSFireTimer + 125
10 CoreFoundation 0x018338c3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
11 CoreFoundation 0x01834e74 __CFRunLoopDoTimer + 1220
12 CoreFoundation 0x017912c9 __CFRunLoopRun + 1817
13 CoreFoundation 0x01790840 CFRunLoopRunSpecific + 208
14 CoreFoundation 0x01790761 CFRunLoopRunInMode + 97
15 GraphicsServices 0x01a8a1c4 GSEventRunModal + 217
16 GraphicsServices 0x01a8a289 GSEventRun + 115
17 UIKit 0x001cbc93 UIApplicationMain + 1160
18 IDogEvents 0x00002349 main + 121
19 IDogEvents 0x000022c5 start + 53
20 ??? 0x00000001 0x0 + 1
请帮助我。在此先感谢。