1.
#define kScreen_Width [UIScreen mainScreen].bounds.size.width
横屏和竖屏的时候,kScreen_Width的值是不一样的.
2.利用系统自带的方法,当屏幕发生转动的时候会自动调用这个方法.在ios9的时候,这个方法不建议使用了.但是我们现在最低适配ios8,所以还是要用这个方法.
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
// UIInterfaceOrientationUnknown = UIDeviceOrientationUnknown,
// home键在下边
// UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,
// home键在上边
// UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
// home键在左边
// UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,
// home键在右边
// UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft
}
判断横屏竖屏的时候,要注意应用都支持哪几个方向.模拟器是不支持home键在上边的时候的显示的.