You can get the screen size by using this code:
CGRect screenBounds = [[UIScreen mainScreen] bounds];
UIViewController *ViewController;
[self loadall];
if (screenBounds.size.height == 568) {
NSLog(@"User is using an iPhone 5+");
BOOL isUsingiPhone5 = YES;
}
else{
NSLog(@"User is using an iPhone 4s-");
BOOL isUsingiPhone5 = NO;
}
then you could move things accordingly, with CGRect
heres an example of moving an ad banner view as a result of the screen size:
-(void)bannerViewDidLoadAd:(ADBannerView *)banner {
CGRect bannerFrame = banner.frame;
CGRect screenBounds = [[UIScreen mainScreen] bounds];
UIViewController *ViewController;
if (screenBounds.size.height == 568) {
//iPhone5+
bannerFrame.origin.x = 0;
bannerFrame.origin.y = 518;
banner.frame = bannerFrame;
}
else{
//iPhone4s-
}
NSLog(@"Showing ad, internet connection found.");
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations];
}
else{
[banner setAlpha:0];
}
Make sure to use ViewController
as the UIViewController
variable, even if your default view controller is named something like RootViewController.
Hope this helps. Feel free to comment if you have any questions!