我在模拟器上测试时,我的ipAd横幅没有出现

时间:2013-08-31 00:15:25

标签: iphone ios

我是新的toiOS,我正试图在顶部放置一个横幅广告,但它不起作用。我知道这是一个糟糕的问题,但老实说我不知道​​所以我需要一些帮助。非常感谢任何帮助。

.h文件

#import <UIKit/UIKit.h>
#import <iAd/iAd.h>
@interface withadViewController : UIViewController <ADBannerViewDelegate> {
ADBannerView *adView;
BOOL bannerIsVisible;
IBOutlet ADBannerView *banner1;
IBOutlet UITextField *textField1;
IBOutlet UITextField *textField2;
IBOutlet UILabel *label1;
}
@property (nonatomic, assign) BOOL bannerIsVisible;
-(IBAction)calculate;
-(IBAction)clear;
@end

和我的.m文件

@synthesize bannerIsVisible;
-(void)bannerViewDidLoadAd:(ADBannerView *)banner
{
if(!self.bannerIsVisible)
{
    [UIView beginAnimations:@"animateBannerOn" context:NULL];
    // banner is invisible now and moved out of the screen on 50px
    banner.frame = CGRectOffset(banner.frame, 320, 50);
    [UIView commitAnimations];
    self.bannerIsVisible = YES;
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible)
{ [UIView beginAnimations:@"animateAdBannerOff" context:NULL];
    // banner is visible and we move it out of the screen, due to connection issue
    banner.frame = CGRectOffset(banner.frame, 0, -320);
    [UIView commitAnimations];
    self.bannerIsVisible = NO;
}
}
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:         -(BOOL)willLeave
{
NSLog(@"Banner view is beginning an ad action");
BOOL shouldExecuteAction = YES;
if (!willLeave && shouldExecuteAction)
{
    // stop all interactive processes in the app
    // [video pause];
    // [audio pause];
}
return shouldExecuteAction;
- (void)viewDidLoad {
[super viewDidLoad];
adView = [[ADBannerView alloc]initWithFrame:CGRectZero];
adView.frame = CGRectOffset(adView.frame, 0, -50);
adView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
adView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.view addSubview:adView];
adView.delegate=self;
self.bannerIsVisible=NO;
[super viewDidLoad];    
@end

0 个答案:

没有答案