Ios iPhone 6/6 Plus上的iAd横幅位置错误
我正在尝试为iPhone 6和iPhone 6 Plus优化我的SpriteKit应用程序,但iAd横幅位置错误,我无法更改。它在4英寸或3.5英寸的iPhone上非常有效,但在iPhone 6和6 Plus上,横幅不在底部,而是在上面一点 另外,我一直在谷歌搜索这个问题。有很多解决方案,但没有一个对我有效 我在ViewController.m文件中为iAd横幅使用以下代码:Ios iPhone 6/6 Plus上的iAd横幅位置错误,ios,objective-c,iphone,iad,Ios,Objective C,Iphone,Iad,我正在尝试为iPhone 6和iPhone 6 Plus优化我的SpriteKit应用程序,但iAd横幅位置错误,我无法更改。它在4英寸或3.5英寸的iPhone上非常有效,但在iPhone 6和6 Plus上,横幅不在底部,而是在上面一点 另外,我一直在谷歌搜索这个问题。有很多解决方案,但没有一个对我有效 我在ViewController.m文件中为iAd横幅使用以下代码: //iAd #pragma mark iAd Delegate Methods - (void)bannerViewD
//iAd
#pragma mark iAd Delegate Methods
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
CGRect screen = [[UIScreen mainScreen] bounds];
CGFloat height = CGRectGetHeight(screen);
banner.frame = CGRectOffset(banner.frame, 0, height-banner.frame.size.height);
//Changing the Y-position doesn't change the banner's position
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
if([[NSUserDefaults standardUserDefaults] boolForKey:@"Ads_savedata"] == NO)
[banner setAlpha:0];
else
[banner setAlpha:1];
[banner updateConstraints];
[UIView commitAnimations];
}
- (void) bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:0];
[UIView commitAnimations];
}
对我来说,下面的一行似乎不会影响横幅的位置
banner.frame = CGRectOffset(banner.frame, 0, height-banner.frame.size.height);
我希望有人能帮我解决这个问题。谢谢您的关注。我想它的屏幕宽度和高度有问题。试试这个
float SW;
float SH;
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (( [[[UIDevice currentDevice] systemVersion] floatValue]<8) && UIInterfaceOrientationIsLandscape(orientation))
{
SW = [[UIScreen mainScreen] bounds].size.height;
SH = [[UIScreen mainScreen] bounds].size.width;
}
else
{
SW = [[UIScreen mainScreen] bounds].size.width;
SH = [[UIScreen mainScreen] bounds].size.height;
}
float-SW;
漂浮物;
UIInterfaceOrientation方向=[UIApplication sharedApplication].StatusBaroOrientation;
如果([[UIDevice currentDevice]系统版本]浮点值]谢谢你的快速回答,但它不起作用。另外,我只在肖像中使用该应用程序。请在此查看示例iAd项目:非常感谢,我能够在你的iAd项目的帮助下解决问题。对于其他有相同问题的人:不要通过将iAd BannerView添加到Main.storyboard中来使用它。你必须创建iAd banner programmatically(iAd文件:)