开发者

iAd Positioning Question

I have my iAd currently displaying at the top, but I believe it will look better at the bottom. How can I modify my code to accomplish this without interface builder. Also if anyone sees any errors, please let me know. This is my first iAd attempt.

- (void)viewDidLoad {

    [super viewDidLoad];

    adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
    adView.frame = CGRectOffset(adView.frame, 0, -50);
    adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
    adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
    [self.view addSubview:adView];
    adView.delegate=self;
    self.bannerIsVisible=NO;
    [super viewDidLoad];

    NSArray *langArray = [[NSArray alloc] initWithObjects:
                      @"Split", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10", nil];

    self.people = langArray;
    [langArray release];

    NSArray *osArray = [[NSArray alloc] initWithObjects:
                        @"0%", @"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%", @"30%", @"35%",
                        @"40%", @"45%", @"50%", nil];
    self.percent = osArray;
    [osArray release];
}

I also added a bann开发者_如何学Pythoner for reference into interface builder and used that to input into the code, that does not work as well.

adView.frame = CGRectOffset(adView.frame, 0, 410);


Please take a look at the iAd implementation example code in the Apple docs. iAdSuite

Their example places the banner across the bottom. It also shows best practices like placing the banner off screen and brings on screen only once the ad is loaded. It also shows code to deal well with orientation chances.


Give this a try:

- (void)viewDidLoad {

    [super viewDidLoad];

    adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
    adView.frame = CGRectOffset(adView.frame, 0, 50);
    adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
    adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
    [self.view addSubview:adView];
    adView.delegate=self;
    self.bannerIsVisible=NO;
    [super viewDidLoad];

    NSArray *langArray = [[NSArray alloc] initWithObjects:
                      @"Split", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10", nil];

    self.people = langArray;
    [langArray release];

    NSArray *osArray = [[NSArray alloc] initWithObjects:
                        @"0%", @"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%", @"30%", @"35%",
                        @"40%", @"45%", @"50%", nil];
    self.percent = osArray;
    [osArray release];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜