3.5インチの時は無し

iPhoneの画面サイズはすっかり大きくなった。
大きいサイズでレイアウトしていると3.5インチに収まらくなる時がある。

そんな時はこっそり広告とかを消しちゃおう。

    //画面サイズによるnendの広告表示非表示
    NSLog(@"%f",[[UIScreen mainScreen] bounds].size.height);
    
    if ([[UIScreen mainScreen] bounds].size.height == 480.000000) {
        self.bannerView.hidden = YES ;
    }

良いのかな?

追記
参考ページ
Auto Layoutでsubviewを動的に非表示にしたときのマージンをどうにかする – 悪あがきプログラマー

マージンのプロパティを作って消したらなお良し。

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *banerView3topConstraint;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *banerView3bottomConstraint;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    //画面サイズによるnendの広告表示非表示
    NSLog(@"%f",[[UIScreen mainScreen] bounds].size.height);
    
    if ([[UIScreen mainScreen] bounds].size.height == 480.000000) {
        self.bannerView3.hidden = YES ;
        self.banerView3topConstraint.constant = 0.f;
        self.banerView3bottomConstraint.constant = 0.f;
    }
}

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です