您的位置:首页 > 移动开发 > IOS开发

ios7横竖屏适配

2013-12-15 20:55 501 查看
/**
*  根据当前屏幕方向,重新定义view的frame
*
*  @param orientation 屏幕方向
*
*  @return 适配后的frame
*/
- (CGRect)frameForOrientation:(UIInterfaceOrientation)orientation
{
CGRect frame;
if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
CGRect bounds = [UIScreen mainScreen].bounds;
frame = CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.height, bounds.size.width);
} else {
frame = [UIScreen mainScreen].bounds;
}
return frame;
}
//ios7- (BOOL)shouldAutorotate{return YES;}//支持的方向- (NSUInteger)supportedInterfaceOrientations{return UIInterfaceOrientationMaskAll;}- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{return YES;}- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration{CGRect frame = [self frameForOrientation:interfaceOrientation];self.webView.frame = frame;//重新定义frame}

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: