UI_USER_INTERFACE_IDIOM() always returns UIUserInterfaceIdiomPhone on iPad 4.3 Simulator?
I am new to iOS development and following along with the book "Learning Cocos2d, A Hands-on Guide to Building iOS Games with Cocos2d, Box2d, and Chipmunk".
I have noticed that the UI buttons and viking characher I have rendered in chapter 2 do not match the book... the apparent cause is that the book instructs you to use the UI_USER_INTERFACE_IDIOM() macro to determine whether you are running an iPad or an iPhone, but it appears that no matter whether I set the scheme in xcode to use iPad 4.3 or iPhone 4.3, the macro always reports that I am running on the phone, not the pad.
Is there some sort of problem with the macro? Is this because I am running only on the simulator? I do not have an开发者_如何学Go actual device on which to test any of this. What am I to do when this macro fails like this?
You need to make sure that your project is configured to build a "Universal" app. An iPhone app running on the iPad will still identify its UI idiom as "iPhone".
精彩评论