- *
- * 根据当前屏幕方向,重新定义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;
- }
- <pre code_snippet_id="113410" snippet_file_name="blog_20131215_3_2421970" name="code" class="objc">//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
- }
- </pre><br>
- <br>
- <pre></pre>
- <p><br>
- </p>
1150

被折叠的 条评论
为什么被折叠?



