一般 iPhone 正常工作(即竖屏)时,坐标原点(0,0)位于左上角。但如果用户把 iPhone 横过来,或者程序是横屏运行的,下面的方法能让横屏开发时坐标原点(0,0)依然位于左上角(当然,如果从纵屏的角度来看就是左下角或者右上角)。
在info.plist中增加一项:
UIInterfaceOrientation
UIInterfaceOrientationLandscapeRight
再加一项 initial interface orientation Landscape(right)
View- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
在 interface builder 中,点选窗口右上角的旋转图标,把窗口视图转成水平的。