I want to use different images in my iPhone application, depending on wheth开发者_StackOverflow中文版er the current device is an iPhone 3G, iPhone 4, or iPad. I've tried getting the screen resolution (size) of the device, but it always returns 320 X 480 for the different iPhones.
How do I determine which type of device I'm running on so that I can provide the correct images?
I do not want to get the iPhone OS version.
There's most likely no need to do what you're attempting to do, as iOS has built in support for loading images at the appropriate size for the iPhone (retina and pre-retina resolutions) and iPad.
Read the Resource Programming Guide (specifically the "Specifying High-Resolution Images in iOS" and "iOS Supports Device-Specific Resources" section) and the iOS Application Programming Guide for more information.
Incidentally, both the pre and post retina iPhone/Pods have a point resolution of 320 X 480. Apple distinguishes between point sizes (resolution independent) and pixel size to help things along the way.
If you want this info for the purposes of selecting the proper graphics for your resolution, then middaparka's answer is what you're looking for.
However, if you happen to need device model or resolution info for a different purpose, then UIDevice and UIScreen may be what you want.
NSString *myDeviceModel = [[UIDevice currentDevice] model];
CGRect myScreenSize = [[UIScreen mainScreen] bounds].size;
i think below one solve my problem
https://github.com/erica/uidevice-extension/blob/master/UIDevice-Hardware.m
Thanks
精彩评论