在 pch 文件中定义:
#define VIEW_HEIGHT_HALF (([[UIScreen mainScreen] bounds].size.height-568)?240:284)
然后我将在 .m 文件中使用它:
struct CGRect gPlayerBox[] =
{
// x, y width, height
{ 40, 40, 320-80, VIEW_HEIGHT_HALF - 40-32 }, // player 1 box
{ 40, VIEW_HEIGHT_HALF+33, 320-80, VIEW_HEIGHT_HALF - 40-32 } // player 2 box
};
但它抛出错误: Initializer element is not a compile-time constant
只是我知道如何解决它?提前致谢!!!