#if check (preprocessor macro) to differentiate between iPhone and iPad

后端 未结 5 1287
别那么骄傲
别那么骄傲 2021-02-04 12:13

Is there a build preprocessor macro I can check, with #if or #ifdef to determine if my current Xcode project is being built for iPhone or iPad?

5条回答
  •  长发绾君心
    2021-02-04 12:58

    Updation for swift:

    Couldn't use preprocessor. Make global function as

    func IS_IPAD() -> Bool { 
    ( return (UIDevice.respondsToSelector(Selector("userInterfaceIdiom"))) && (UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad) )}
    

提交回复
热议问题