iDev
[개발] iPod touch인지 iPhone 인지 구분하기
KraZYeom
2009. 1. 13. 07:56
반응형
enum
{
MODEL_IPHONE_SIMULATOR,
MODEL_IPOD_TOUCH,
MODEL_IPHONE,
MODEL_IPHONE_3G
};
// 메소드
UIDevice *currentDevice = [UIDevice currentDevice]; // 무슨 기기인지??? 이거 한줄이면 되죠.
NSString *iPodTouch = @"iPod touch";
NSString *iPhoneSimulator = @"iPhone Simulator";
NSString *model= [currentDevice model];
NSString *detected;
if ( [model compare:iPhoneSimulator] == NSOrderedSame ) // iPhone simulator
{
detected = @"home_touch.png";
}
else if ( [model compare:iPodTouch] == NSOrderedSame ) // iPod Touch
{
detected = @"home_touch.png";
}
else // Could be an iPhone V1 or iPhone 3G (model should be "iPhone")
{
// Detect if we are running on an iPhone 3G
{
struct utsname u;
uname( &u ); // u.machine could be "i386" for the simulator, "iPod1,1" on iPod Touch, "iPhone1,1" on iPhone V1 & "iPhone1,2" on iPhone3G
if ( !strcmp( u.machine, "iPhone1,1" ) )
{
detected = @"home_iphone.png";
}
else
{
detected = @"home_iphone.png";
}
}
}
뭐 이런식으로 하면 구분을 할 수 있죠.
반응형