From 5a4bcb83417d220511ca31c66db4db5ca7f195e6 Mon Sep 17 00:00:00 2001 From: Elliot Date: Thu, 28 Aug 2014 17:55:58 -0700 Subject: [PATCH] Add iPhone compatibility. --- RangeSelector.xcodeproj/project.pbxproj | 2 ++ RangeSelector/RangeSelector-Info.plist | 5 +++++ RangeSelector/ViewController.m | 17 ++++++++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/RangeSelector.xcodeproj/project.pbxproj b/RangeSelector.xcodeproj/project.pbxproj index 3fa0e12..6f615db 100644 --- a/RangeSelector.xcodeproj/project.pbxproj +++ b/RangeSelector.xcodeproj/project.pbxproj @@ -551,6 +551,7 @@ GCC_PREFIX_HEADER = "RangeSelector/RangeSelector-Prefix.pch"; INFOPLIST_FILE = "RangeSelector/RangeSelector-Info.plist"; PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; WRAPPER_EXTENSION = app; }; name = Debug; @@ -566,6 +567,7 @@ GCC_PREFIX_HEADER = "RangeSelector/RangeSelector-Prefix.pch"; INFOPLIST_FILE = "RangeSelector/RangeSelector-Info.plist"; PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; WRAPPER_EXTENSION = app; }; name = Release; diff --git a/RangeSelector/RangeSelector-Info.plist b/RangeSelector/RangeSelector-Info.plist index 0d75e78..20cc0f6 100644 --- a/RangeSelector/RangeSelector-Info.plist +++ b/RangeSelector/RangeSelector-Info.plist @@ -30,6 +30,11 @@ armv7 + UISupportedInterfaceOrientations + + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + UISupportedInterfaceOrientations~ipad UIInterfaceOrientationPortrait diff --git a/RangeSelector/ViewController.m b/RangeSelector/ViewController.m index ad8194f..a7e60d4 100644 --- a/RangeSelector/ViewController.m +++ b/RangeSelector/ViewController.m @@ -38,11 +38,26 @@ - (void)viewDidLoad [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. datasource = [[ChartDatasource alloc] init]; - rangeSelector = [[ShinobiRangeSelector alloc] initWithFrame:self.view.bounds datasource:datasource splitProportion:0.75f]; + // Make frame landscape on iPhone. + CGRect frame = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? self.view.bounds : [self landscapeFrame]; + rangeSelector = [[ShinobiRangeSelector alloc] initWithFrame:frame datasource:datasource splitProportion:0.75f]; [self.view addSubview:rangeSelector]; } +- (CGRect)landscapeFrame +{ + // make it landscape + CGRect frame = self.view.bounds; + CGFloat width = self.view.bounds.size.width; + if (frame.size.height > width) { + // swap width <-> height + frame.size.width = frame.size.height; + frame.size.height = width; + } + return frame; +} + - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning];