RSS

(root)/iphone/common : /source/NSObject_DeviceDetection.m (revision 100)

To get this branch, use:
bzr branch /browse/iphone/common
Line Revision Contents
1 63
//
2
//  NSObject_DeviceDetection.m
3
//  Jigs
4
//
5
//  Created by döme on 12.04.2010.
6
//  Copyright 2010 __MyCompanyName__. All rights reserved.
7
//
8
9
#import "NSObject_DeviceDetection.h"
10
11
12
@implementation NSObject (DeviceDetection)
13
14 94
- (BOOL) isItAPad2
15
{
16
	NSString* model = [[UIDevice currentDevice] model];
17
	NSLog(@"model; %@", model);
18
	#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2
19
		return UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad;
20
	#else
21
		return NO;
22
	#endif
23
}
24
25
26 63
- (BOOL) isItAPad
27
{
28 70
	#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2
29 63
		return UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad;
30
	#else
31
		return NO;
32
	#endif
33
}
34
35
- (BOOL) isItAPhone
36
{
37 70
	#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2
38 63
		return UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone;
39
	#else
40
		return YES;
41
	#endif
42
}
43
44 65
static uint32_t nextPot(uint32_t v)
45
{
46
	v--;
47
	v |= v >> 1;
48
	v |= v >> 2;
49
	v |= v >> 4;
50
	v |= v >> 8;
51
	v |= v >> 16;
52
	v++;
53
return v;
54
}
55
56
- (uint32_t) fullScreenTexturePotSize
57
{
58 69
	UIScreen* screen = [UIScreen mainScreen];
59
60
	CGSize size = CGSizeMake(320.0f,480.0f);
61
	if ([screen respondsToSelector: @selector(currentMode)]) // iOS 3.2 and later only
62
		size = screen.currentMode.size;
63
	
64
65 65
	uint32_t px = fmaxf(size.width,size.height);
66
	return nextPot(px);
67
	
68
}
69
70 96.1.1
- (BOOL) is2xDisplay
71
{
72
	return [UIScreen mainScreen].scale > 1.0;
73
}
74
75 63
@end
76

Loggerhead 1.17 is a web-based interface for Bazaar branches