你不需要硬編碼,高度和寬度,只是宏觀的東西,假設你是呈現全屏模式:
#define SCREEN_WIDTH ((([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) || ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown)) ? [[UIScreen mainScreen] bounds].size.width : [[UIScreen mainScreen] bounds].size.height)
#define SCREEN_HEIGHT ((([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) || ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown)) ? [[UIScreen mainScreen] bounds].size.height : [[UIScreen mainScreen] bounds].size.width)
你可以這樣稱呼它們:
SCREEN_HEIGHT和SCREEN_WIDTH;
從你的問題的長相,在UIViewController中被提出,其大小與一臺iPad一樣,所以這個窗口的大小與該應用程序的窗口一樣,讓你的框架是這樣的:
CGRectMake(0,0,SCREEN_WIDTH,SCREEN_HEIGHT)
1024 x 768,聽起來像iPad或其他東西,對吧? – Loxx