Browse files

Move the iPhone iPad testing to a UIDevice Category.

Closes #21
  • Loading branch information...
1 parent d7be4e5 commit 3a6295192a4f8837ec535ee032b2e936bf356ab8 @jaygraves jaygraves committed Dec 8, 2011
View
7 DETweetComposeViewController/DETweetComposeViewController.m
@@ -13,6 +13,7 @@
#import "OAuth+DEExtensions.h"
#import <QuartzCore/QuartzCore.h>
#import "UIApplication+DETweetComposeViewController.h"
+#import "UIDevice+DETweetComposeViewController.h"
@interface DETweetComposeViewController ()
@@ -261,7 +262,7 @@ - (void)viewWillDisappear:(BOOL)animated
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
- if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
+ if ([UIDevice isPhone]) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
else {
@@ -278,7 +279,7 @@ - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interf
CGFloat titleLabelFontSize, titleLabelTop;
CGFloat characterCountLeft, characterCountTop;
- if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
+ if ([UIDevice isPhone]) {
cardWidth = CGRectGetWidth(self.view.bounds) - 10.0f;
if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
cardTop = 25.0f;
@@ -361,7 +362,7 @@ - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interf
characterCountLeft = CGRectGetWidth(self.cardView.frame) - CGRectGetWidth(self.characterCountLabel.frame) - 12.0f;
characterCountTop = CGRectGetHeight(self.cardView.frame) - CGRectGetHeight(self.characterCountLabel.frame) - 8.0f;
- if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
+ if ([UIDevice isPhone]) {
if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
characterCountTop -= 5.0f;
if ([self attachmentsCount] > 0) {
View
16 DETweetComposeViewController/UIDevice+DETweetComposeViewController.h
@@ -0,0 +1,16 @@
+//
+// UIDevice+DETweetComposeViewController.h
+// DETweeter
+//
+// Created by James Graves on 12/7/11.
+// Copyright (c) 2011 Double Encore, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface UIDevice (DETweetComposeViewController)
+
++ (BOOL)isPad;
++ (BOOL)isPhone;
+
+@end
View
23 DETweetComposeViewController/UIDevice+DETweetComposeViewController.m
@@ -0,0 +1,23 @@
+//
+// UIDevice+DETweetComposeViewController.m
+// DETweeter
+//
+// Created by James Graves on 12/7/11.
+// Copyright (c) 2011 Double Encore, Inc. All rights reserved.
+//
+
+#import "UIDevice+DETweetComposeViewController.h"
+
+@implementation UIDevice (DETweetComposeViewController)
+
++ (BOOL)isPad
+{
+ return [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad ? YES : NO;
+}
+
++ (BOOL)isPhone
+{
+ return [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ? YES : NO;
+}
+
+@end
View
10 DETweeter.xcodeproj/project.pbxproj
@@ -31,10 +31,11 @@
6925A8301459105500011DA0 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 6925A82F1459105500011DA0 /* libz.dylib */; };
695D657C1466093D0002D720 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 695D657B1466093D0002D720 /* Default.png */; };
695D657E146609430002D720 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 695D657D146609430002D720 /* Default@2x.png */; };
+ 697FE2CF14903C750045B8C7 /* UIDevice+DETweetComposeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 697FE2CE14903C750045B8C7 /* UIDevice+DETweetComposeViewController.m */; };
699A29BB1459B3960046B260 /* DETweetPoster.m in Sources */ = {isa = PBXBuildFile; fileRef = 699A29BA1459B3960046B260 /* DETweetPoster.m */; };
69E70E8A1484BAD5004A66CA /* DEHTTPRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 69E70E891484BAD5004A66CA /* DEHTTPRequest.m */; };
- 69F126411489A81C00343C3D /* YawkeyBusinessDog.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 69F126401489A81C00343C3D /* YawkeyBusinessDog.jpg */; };
69EC1CC114885748002DB78F /* UIApplication+DETweetComposeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 69EC1CC014885748002DB78F /* UIApplication+DETweetComposeViewController.m */; };
+ 69F126411489A81C00343C3D /* YawkeyBusinessDog.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 69F126401489A81C00343C3D /* YawkeyBusinessDog.jpg */; };
B60F06991486F0C000CE3BD6 /* icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = B60F06981486F0C000CE3BD6 /* icon@2x.png */; };
B60F069C1486F0ED00CE3BD6 /* icon~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = B60F069B1486F0ED00CE3BD6 /* icon~ipad.png */; };
B639E5261486D2DA0054AE8F /* background.png in Resources */ = {isa = PBXBuildFile; fileRef = B639E5251486D2DA0054AE8F /* background.png */; };
@@ -125,14 +126,16 @@
6925A82F1459105500011DA0 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
695D657B1466093D0002D720 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Default.png; path = ../Default.png; sourceTree = "<group>"; };
695D657D146609430002D720 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "../Default@2x.png"; sourceTree = "<group>"; };
+ 697FE2CD14903C750045B8C7 /* UIDevice+DETweetComposeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIDevice+DETweetComposeViewController.h"; path = "DETweetComposeViewController/UIDevice+DETweetComposeViewController.h"; sourceTree = SOURCE_ROOT; };
+ 697FE2CE14903C750045B8C7 /* UIDevice+DETweetComposeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIDevice+DETweetComposeViewController.m"; path = "DETweetComposeViewController/UIDevice+DETweetComposeViewController.m"; sourceTree = SOURCE_ROOT; };
6980DB8714738CF4002282CB /* README.markdown */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.markdown; sourceTree = "<group>"; };
699A29B91459B3960046B260 /* DETweetPoster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DETweetPoster.h; path = ../DETweetComposeViewController/DETweetPoster.h; sourceTree = "<group>"; };
699A29BA1459B3960046B260 /* DETweetPoster.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DETweetPoster.m; path = ../DETweetComposeViewController/DETweetPoster.m; sourceTree = "<group>"; };
69E70E881484BAD5004A66CA /* DEHTTPRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DEHTTPRequest.h; sourceTree = "<group>"; };
69E70E891484BAD5004A66CA /* DEHTTPRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DEHTTPRequest.m; sourceTree = "<group>"; };
- 69F126401489A81C00343C3D /* YawkeyBusinessDog.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = YawkeyBusinessDog.jpg; sourceTree = "<group>"; };
69EC1CBF14885748002DB78F /* UIApplication+DETweetComposeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIApplication+DETweetComposeViewController.h"; path = "DETweetComposeViewController/UIApplication+DETweetComposeViewController.h"; sourceTree = SOURCE_ROOT; };
69EC1CC014885748002DB78F /* UIApplication+DETweetComposeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIApplication+DETweetComposeViewController.m"; path = "DETweetComposeViewController/UIApplication+DETweetComposeViewController.m"; sourceTree = SOURCE_ROOT; };
+ 69F126401489A81C00343C3D /* YawkeyBusinessDog.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = YawkeyBusinessDog.jpg; sourceTree = "<group>"; };
B60F06981486F0C000CE3BD6 /* icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "icon@2x.png"; path = "../icon@2x.png"; sourceTree = "<group>"; };
B60F069B1486F0ED00CE3BD6 /* icon~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "icon~ipad.png"; path = "../icon~ipad.png"; sourceTree = "<group>"; };
B639E5251486D2DA0054AE8F /* background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = background.png; sourceTree = "<group>"; };
@@ -394,6 +397,8 @@
B6B6CCF214586015005B93A1 /* Images */,
69EC1CBF14885748002DB78F /* UIApplication+DETweetComposeViewController.h */,
69EC1CC014885748002DB78F /* UIApplication+DETweetComposeViewController.m */,
+ 697FE2CD14903C750045B8C7 /* UIDevice+DETweetComposeViewController.h */,
+ 697FE2CE14903C750045B8C7 /* UIDevice+DETweetComposeViewController.m */,
);
name = DETweetComposeViewController;
path = DETweeter;
@@ -546,6 +551,7 @@
B69AB9B414869A5C00652DDF /* DETweetGradientView.m in Sources */,
B69C605A14894F4D00A18C1B /* DETweetRuledView.m in Sources */,
69EC1CC114885748002DB78F /* UIApplication+DETweetComposeViewController.m in Sources */,
+ 697FE2CF14903C750045B8C7 /* UIDevice+DETweetComposeViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
4 DETweeter/DEAppDelegate.m
@@ -7,7 +7,7 @@
#import "DEAppDelegate.h"
#import "DEViewController.h"
-
+#import "UIDevice+DETweetComposeViewController.h"
@implementation DEAppDelegate
@@ -36,7 +36,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
- if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
+ if ([UIDevice isPhone]) {
self.viewController = [[[DEViewController alloc] initWithNibName:@"DEViewController_iPhone" bundle:nil] autorelease];
}
else {
View
6 DETweeter/DEViewController.m
@@ -12,7 +12,7 @@
#import "OAuthConsumerCredentials.h"
#import <Twitter/Twitter.h>
#import <QuartzCore/QuartzCore.h> // Just for testing
-
+#import "UIDevice+DETweetComposeViewController.h"
@interface DEViewController ()
@@ -72,7 +72,7 @@ - (void)viewDidLoad
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
- if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
+ if ([UIDevice isPhone]) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
else {
@@ -85,7 +85,7 @@ - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interf
{
CGRect frame = self.buttonView.frame;
frame.origin.x = trunc((self.view.bounds.size.width - frame.size.width) / 2);
- if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
+ if ([UIDevice isPhone]) {
frame.origin.y = UIInterfaceOrientationIsPortrait(interfaceOrientation) ? 306.0f : 210.0f;
}
else {

0 comments on commit 3a62951

Please sign in to comment.