use*_*142 22 iphone objective-c ipad ios
可能重复:以
编程方式检测应用程序是否正在设备或模拟器上运行
如何通过代码检测我的应用程序是在Simulator上运行还是在设备上运行
fuz*_*uzz 77
请记住,UIDevice您已经获得了有关设备本身的信息.
[[UIDevice currentDevice] model]
您还可以使用以下内容:
TARGET_IPHONE_SIMULATOR 告诉你你是否在iPhone模拟器中.
TARGET_OS_IPHONE 告诉你,你正在使用iPhone而不是MacOS.
#if TARGET_IPHONE_SIMULATOR
NSLog(@"Running in Simulator - no app store or giro");
#else
NSLog(@"Running on the Device");
#endif
Run Code Online (Sandbox Code Playgroud)
当只对设备感兴趣时
#if !(TARGET_IPHONE_SIMULATOR)
NSLog(@"Running on device");
#endif
Run Code Online (Sandbox Code Playgroud)
小智 8
你可以使用这个常数
#if TARGET_OS_SIMULATOR
NSLog(@"This is simulator mode....");
#else
NSLog(@"This is device mode....");
#endif
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18709 次 |
| 最近记录: |