- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
//----------------HERE WE SETUP FOR IPHONE 4/4s/iPod----------------------
if(iOSDeviceScreenSize.height == 480){
UIStoryboard *iPhone35Storyboard = [UIStoryboard storyboardWithName:@"iPhone" bundle:nil];
// Instantiate the initial view controller object from the storyboard
UIViewController *initialViewController = [iPhone35Storyboard instantiateInitialViewController];
// Instantiate a UIWindow object and initialize it with the screen size of the iOS device
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Set the initial view controller to be the root view controller of the window object
self.window.rootViewController = initialViewController;
// Set the window object to be the key window and show it
[self.window makeKeyAndVisible];
iphone=@"4";
NSLog(@"iPhone 4: %f", iOSDeviceScreenSize.height);
}
//----------------HERE WE SETUP FOR IPHONE 5----------------------
if(iOSDeviceScreenSize.height == 568){
// Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone4
UIStoryboard *iPhone4Storyboard = [UIStoryboard storyboardWithName:@"iPhone5" bundle:nil];
// Instantiate the initial view controller object from the storyboard
UIViewController *initialViewController = [iPhone4Storyboard instantiateInitialViewController];
// Instantiate a UIWindow object and initialize it with the screen size of the iOS device
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Set the initial view controller to be the root view controller of the window object
self.window.rootViewController = initialViewController;
// Set the window object to be the key window and show it
[self.window makeKeyAndVisible];
NSLog(@"iPhone 5: %f", iOSDeviceScreenSize.height);
iphone=@"5";
}
} else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// NSLog(@"wqweqe");
storyboard = [UIStoryboard storyboardWithName:@"iPad" bundle:nil];
}
return YES;
}
import UIKit
@objc(IphoneModelScreenSize)
public class IphoneModelScreenSize: NSObject {
// MARK: Enums
public enum IphoneModelScreenSize: Int {
case notAnIphone = 0,
twoThreeOrFour = 1,
se = 2,
sixSevenOrEight = 3,
plus = 4,
elevenXorXS = 5,
elevenProMaxOrXsMax = 6
}
// MARK: Class properties
public class func screenSize() -> IphoneModelScreenSize {
let bounds = UIScreen.main.bounds
let screenWidth = bounds.size.width
let screenHeight = bounds.size.height
switch (screenWidth, screenHeight) {
case (320.0, 480.0):
return .twoThreeOrFour
case (320.0, 568.0):
return .se
case (375.0, 667.0):
return .sixSevenOrEight
case (414.0, 736.0):
return .plus
case (375.0, 812.0):
return .elevenXorXS
case (414.0, 896.0):
return .elevenProMaxOrXsMax
default:
return .notAnIphone
}
}
public class func screenSizeStringValue() -> String {
return screenSizeEnumToString(screenSize())
}
// MARK: Private properties
private class func screenSizeEnumToString(_ screenSize: IphoneModelScreenSize) -> String {
var screenSizeAsString: String
switch screenSize {
case .notAnIphone:
screenSizeAsString = "Not an Iphone"
case .twoThreeOrFour:
screenSizeAsString = "2G, 3G, 3GS, 4 or 4s"
case .se:
screenSizeAsString = "5, 5s, 5c or SE"
case .sixSevenOrEight:
screenSizeAsString = "6, 6s, 7 or 8"
case .plus:
screenSizeAsString = "6+, 6s+, 7+ or 8+"
case .elevenXorXS:
screenSizeAsString = "11 Pro, X or Xs"
case .elevenProMaxOrXsMax:
screenSizeAsString = "11, Xr, 11 Pro Max or Xs Max"
}
return screenSizeAsString
}
}