Skip to content

Commit

Permalink
Added width test to determine platform for Simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
Erica Sadun authored and Erica Sadun committed Feb 14, 2010
1 parent 0f60a96 commit d20d200
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 25 deletions.
Binary file added Default-Landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Default-Portrait.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions HelloWorld.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
8E4156E70FA4EE0E0006D27C /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = "<group>"; };
8E4156E80FA4EE0E0006D27C /* icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon.png; sourceTree = "<group>"; };
8E785FCA0FCDB853006EA81F /* TestBedViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TestBedViewController.xib; sourceTree = "<group>"; };
8E7D45921128878A00B184C5 /* Default-Landscape.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-Landscape.png"; sourceTree = "<group>"; };
8E7D45931128878A00B184C5 /* Default-Portrait.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-Portrait.png"; sourceTree = "<group>"; };
8E7EA6621028A1A7004DB9E8 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; };
8E9B233D101E2BB0005DB65B /* UIDevice-Reachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIDevice-Reachability.h"; sourceTree = "<group>"; };
8E9B233E101E2BB0005DB65B /* UIDevice-Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIDevice-Reachability.m"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -74,6 +76,7 @@
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
isa = PBXGroup;
children = (
8E7D458C1128875900B184C5 /* Resources-iPad */,
29B97316FDCFA39411CA2CEA /* main.m */,
8E3E64B71028A0EB0009F50A /* UIDevice-Hardware.h */,
8E3E64BA1028A0EB0009F50A /* UIDevice-Hardware.m */,
Expand Down Expand Up @@ -110,9 +113,18 @@
name = Apple;
sourceTree = "<group>";
};
8E7D458C1128875900B184C5 /* Resources-iPad */ = {
isa = PBXGroup;
children = (
);
name = "Resources-iPad";
sourceTree = "<group>";
};
8EB688610FA64AD100489E4B /* Support */ = {
isa = PBXGroup;
children = (
8E7D45921128878A00B184C5 /* Default-Landscape.png */,
8E7D45931128878A00B184C5 /* Default-Portrait.png */,
8E785FCA0FCDB853006EA81F /* TestBedViewController.xib */,
8E3A1F080FAA199F009B0518 /* cover320x416.png */,
32CA4F630368D1EE00C91783 /* HelloWorld_Prefix.pch */,
Expand Down Expand Up @@ -204,6 +216,8 @@
INFOPLIST_FILE = Info.plist;
PREBINDING = NO;
PRODUCT_NAME = HelloWorld;
SDKROOT = iphoneos3.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
Expand All @@ -218,6 +232,8 @@
INFOPLIST_FILE = Info.plist;
PREBINDING = NO;
PRODUCT_NAME = HelloWorld;
SDKROOT = iphoneos3.2;
TARGETED_DEVICE_FAMILY = "1,2";
WRAPPER_EXTENSION = app;
};
name = Release;
Expand Down
67 changes: 45 additions & 22 deletions TestBedViewController.xib
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.03">
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">768</int>
<string key="IBDocument.SystemVersion">9J61</string>
<string key="IBDocument.InterfaceBuilderVersion">680</string>
<string key="IBDocument.AppKitVersion">949.46</string>
<string key="IBDocument.HIToolboxVersion">353.00</string>
<string key="IBDocument.SystemVersion">10C540</string>
<string key="IBDocument.InterfaceBuilderVersion">760</string>
<string key="IBDocument.AppKitVersion">1038.25</string>
<string key="IBDocument.HIToolboxVersion">458.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">82</string>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="35"/>
Expand All @@ -16,7 +20,7 @@
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<object class="NSArray" key="dict.sortedKeys" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
Expand All @@ -27,9 +31,11 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBProxyObject" id="372490531">
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBProxyObject" id="843779117">
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUIView" id="440620744">
<reference key="NSNextResponder"/>
Expand All @@ -45,6 +51,8 @@
<bool key="IBUIClipsSubviews">YES</bool>
<int key="IBUIContentMode">4</int>
<bool key="IBUIMultipleTouchEnabled">YES</bool>
<int key="IBUITag">999</int>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<object class="NSCustomResource" key="IBUIImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">cover320x416.png</string>
Expand All @@ -58,6 +66,7 @@
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIMultipleTouchEnabled">YES</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBUIShowsHorizontalScrollIndicator">NO</bool>
<bool key="IBUIDelaysContentTouches">NO</bool>
<bool key="IBUICanCancelContentTouches">NO</bool>
Expand All @@ -66,6 +75,7 @@
<string key="IBUIText"/>
<object class="IBUITextInputTraits" key="IBUITextInputTraits">
<int key="IBUIAutocapitalizationType">2</int>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
</object>
</object>
Expand All @@ -83,6 +93,7 @@
<object class="IBUISimulatedNavigationBarMetrics" key="IBUISimulatedTopBarMetrics">
<bool key="IBUIPrompted">NO</bool>
</object>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
Expand Down Expand Up @@ -110,22 +121,20 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<object class="NSArray" key="object" id="884947135">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="object" ref="0"/>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="372490531"/>
<reference key="parent" ref="884947135"/>
<string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="843779117"/>
<reference key="parent" ref="884947135"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">32</int>
Expand All @@ -135,7 +144,7 @@
<reference ref="1064941195"/>
<reference ref="311618606"/>
</object>
<reference key="parent" ref="884947135"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">34</int>
Expand All @@ -151,7 +160,7 @@
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.CustomClassName</string>
<string>-2.CustomClassName</string>
Expand All @@ -170,19 +179,15 @@
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="dict.sortedKeys" ref="0"/>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="dict.sortedKeys" ref="0"/>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
Expand All @@ -197,7 +202,7 @@
<string key="className">TestBedViewController</string>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>textView</string>
<string>view</string>
Expand All @@ -216,8 +221,26 @@
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
<integer value="768" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
<integer value="800" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
<integer value="3000" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<string key="IBDocument.LastKnownRelativeProjectPath">HelloWorld.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<string key="IBCocoaTouchPluginVersion">3.1</string>
<object class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
<string key="NS.key.0">cover320x416.png</string>
<string key="NS.object.0">{320, 416}</string>
</object>
<string key="IBCocoaTouchPluginVersion">82</string>
</data>
</archive>
8 changes: 6 additions & 2 deletions UIDevice-Hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@
#define IPAD_1G_NAMESTRING @"iPad 1G"
#define IPAD3G_1G_NAMESTRING @"iPad3G 1G"

#define IPOD_FAMILY_UNKNOWN_DEVICE @"Unknown device in the iPhone/iPod family"
#define IPOD_FAMILY_UNKNOWN_DEVICE @"Unknown device in the iPhone/iPod family"

#define IPHONE_SIMULATOR_NAMESTRING @"iPhone Simulator"
#define IPHONE_SIMULATOR_NAMESTRING @"iPhone Simulator"
#define IPHONE_SIMULATOR_IPHONE_NAMESTRING @"iPhone Simulator"
#define IPHONE_SIMULATOR_IPAD_NAMESTRING @"iPad Simulator"

typedef enum {
UIDeviceUnknown,
UIDeviceiPhoneSimulator,
UIDeviceiPhoneSimulatoriPhone,
UIDeviceiPhoneSimulatoriPad,
UIDevice1GiPhone,
UIDevice3GiPhone,
UIDevice3GSiPhone,
Expand Down
12 changes: 11 additions & 1 deletion UIDevice-Hardware.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,15 @@ - (NSUInteger) platformType
if ([platform hasPrefix:@"iPhone"]) return UIDeviceUnknowniPhone;
if ([platform hasPrefix:@"iPod"]) return UIDeviceUnknowniPod;

if ([platform hasSuffix:@"86"]) return UIDeviceiPhoneSimulator;
if ([platform hasSuffix:@"86"])
{
if ([[UIScreen mainScreen] bounds].size.width < 768)
return UIDeviceiPhoneSimulatoriPhone;
else
return UIDeviceiPhoneSimulatoriPad;

return UIDeviceiPhoneSimulator;
}
return UIDeviceUnknown;
}

Expand All @@ -153,6 +161,8 @@ - (NSString *) platformString
case UIDevice1GiPad3G : return IPAD3G_1G_NAMESTRING;

case UIDeviceiPhoneSimulator: return IPHONE_SIMULATOR_NAMESTRING;
case UIDeviceiPhoneSimulatoriPhone: return IPHONE_SIMULATOR_IPHONE_NAMESTRING;
case UIDeviceiPhoneSimulatoriPad: return IPHONE_SIMULATOR_IPAD_NAMESTRING;

case UIDeviceiProd1G: return IPROD_1G_NAMESTRING;
case UIDeviceiProd2G: return IPROD_2G_NAMESTRING;
Expand Down
9 changes: 9 additions & 0 deletions main.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ - (void) action: (UIBarButtonItem *) bbi
*/

// TESTING DEVICE HARDWARE
[self doLog:@"Platform: %@", [[UIDevice currentDevice] platform]];
[self doLog:@"Platform String: %@", [[UIDevice currentDevice] platformString]];

/*
[self doLog:@"Device is%@ portrait", [UIDevice currentDevice].isPortrait ? @"" : @" not"];
[self doLog:@"Orientation: %@", [UIDevice currentDevice].orientationString];
Expand All @@ -80,6 +83,12 @@ - (void) viewDidLoad
{
self.navigationController.navigationBar.tintColor = COOKBOOK_PURPLE_COLOR;
self.navigationItem.rightBarButtonItem = BARBUTTON(@"Action", @selector(action:));
if ([[[UIDevice currentDevice] platformString] hasPrefix:@"iPad"])
{
UIImageView *imgView = (UIImageView *)[self.view viewWithTag:999];
imgView.frame = [[UIScreen mainScreen] applicationFrame];
imgView.image = [UIImage imageNamed:([[UIDevice currentDevice] isLandscape]) ? @"Default-Landscape.png" : @"Default-Portrait.png"];
}
}
@end

Expand Down

0 comments on commit d20d200

Please sign in to comment.