我已阅读#if和#define语句的许多定义。
我试图用我的阅读方式,但只与错误就行了,它定义了如下评论“在预处理表达开始无效令牌”:#define或#if语句错误
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#define is_ipad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define is_ipad_hd ((is_ipad == 1 && [UIScreen mainScreen].bounds.size.width > 1024) ? YES : NO)
#define is_iphone_hd ([UIScreen mainScreen].bounds.size.width > 480 ? YES : NO)
#define device_width 480.0f
#define device_height 320.0f
#if (is_ipad_hd == YES) // Error here
#define device_width = 2048.0f
#define device_height = 1496.0f
#endif
为什么它在简单的教程,当我们尝试更复杂的事情时,会发生这些事情!
预编译指令在编译之前进行评估;很显然,他们无法运行运行时信息。 (我不知道Objective C,但'[UIScreen mainScreen] .bounds.size.width'听起来像是一个运行时的事情...) –
好吧,现在我明白了。 那么如何指定设备的屏幕尺寸? 对不起,我的慢,因为一些英文研究技术很难翻译,看起来应该是我想象的方式。 –