使用代碼:
self.view.frame.size.width;
self.view.frame.size.height;
第一次的得到了屏幕尺寸,以後就報錯了。應該怎麼修復?
獲取屏幕尺寸,看一下代表屏幕本身的對象:
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;