单独的页面支持横竖屏的状态调整,HTML5加载下

工程中设置只支持竖屏状态,在加载HTML5的界面可以是横竖屏的,在不对工程其他界面/设置做调整的同时,可以这样去

#import "ViewController.h"

#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)

#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)

@interface ViewController ()<UIWebViewDelegate>
{
UIWebView *webview; UIButton * back; } @end @implementation ViewController //此状态一定要是 NO 不然无法对旋转后的尺寸进行适配
-(BOOL)shouldAutorotate{ return NO;
}
//支持的状态
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
// 如果该界面需要支持横竖屏切换
return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortrait; } -(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated]; // self.tabBarController.tabBar.hidden = YES; // self.navigationController.navigationBar.hidden= NO;
//
//
// //隐藏 状态栏
// [[UIApplication sharedApplication]setStatusBarHidden:YES];
// }
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
// self.tabBarController.tabBar.hidden = NO;
// self.navigationController.navigationBar.hidden= NO;
// [[UIApplication sharedApplication]setStatusBarHidden:NO];
// } - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view. [self CreatUI]; //横屏同志UIApplicationDidChangeStatusBarFrameNotification UIDeviceOrientationDidChangeNotification
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange) name:UIDeviceOrientationDidChangeNotification object:nil];
} -(void)CreatUI{ self.view.backgroundColor = [UIColor blackColor]; webview = [[UIWebView alloc] initWithFrame:self.view.bounds]; [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.cnblogs.com/xujiahui/p/6583204.html"]]]];
webview.delegate = self; webview.scalesPageToFit = YES;
// webview.scrollView.scrollEnabled = NO;
[self.view addSubview:webview]; //back。是一个button
//back = [myButton buttonWithType:UIButtonTypeCustom frame:CGRectMake(self.view.frame.size.width-80, self.view.frame.size.height-100, 40,40) tag:1 image:nil andBlock:^(myButton *button) { back= [[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width-, self.view.frame.size.height-, ,)]; [self.navigationController popViewControllerAnimated:YES]; back.backgroundColor = [UIColor greenColor]; [self.view addSubview:back]; } //横屏//横屏 状态下 width和height是颠倒的
- (void)deviceOrientationDidChange
{
NSLog(@"deviceOrientationDidChange:%ld",(long)[UIDevice currentDevice].orientation); if([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait) { [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait]; [UIView animateWithDuration:0.3f animations:^{ self.view.transform = CGAffineTransformMakeRotation();
self.view.bounds = CGRectMake(, , SCREEN_WIDTH, SCREEN_HEIGHT); webview.frame = self.view.bounds; back.frame = CGRectMake(SCREEN_WIDTH-, SCREEN_HEIGHT-, , ); }]; //注意: UIDeviceOrientationLandscapeLeft 与 UIInterfaceOrientationLandscapeRight
} else if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeLeft ) { [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight]; [UIView animateWithDuration:0.3f animations:^{ self.view.transform = CGAffineTransformMakeRotation(M_PI_2); self.view.bounds = CGRectMake(, , SCREEN_HEIGHT, SCREEN_WIDTH); webview.frame = self.view.bounds; back.frame = CGRectMake(SCREEN_WIDTH-, SCREEN_HEIGHT-, , ); }]; }else if ( [UIDevice currentDevice].orientation== UIDeviceOrientationLandscapeRight){ [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft]; [UIView animateWithDuration:0.3f animations:^{ self.view.transform = CGAffineTransformMakeRotation(-M_PI_2); self.view.bounds = CGRectMake(, ,SCREEN_HEIGHT, SCREEN_WIDTH); webview.frame = self.view.bounds; back.frame = CGRectMake(SCREEN_WIDTH-, SCREEN_HEIGHT-, , ); }];
}
} @end

ios单独的页面支持横竖屏的状态调整,HTML5加载下(更新2)的更多相关文章

  1. iOS 实现单个页面支持横竖屏,其他页面只能竖屏

    最近在自己的项目里面 有需要做一个需求 : app中某一个页面支持横竖屏, 而其他页面只能竖屏. 1 2 实现方法如下: 1 首先需要Xcode中选中支持的屏幕方向  2 Appdelegate中 . ...

  2. Android横竖屏切换及其对应布局加载问题

    第一,横竖屏切换连带横竖屏布局问题: 如果要让软件在横竖屏之间切换,由于横竖屏的高宽会发生转换,有可能会要求不同的布局. 可以通过以下两种方法来切换布局: 1)在res目录下建立layout-land ...

  3. iOS 从Xcode看应用支持横竖屏

    要看一个应用是否支持横竖屏,要看Xcode里面的info.plist文件设置才清楚,每一个新建工程都会包含三个支持方式,即Supported interface orientations里面的就是 P ...

  4. 为不同分辨率单独做样式文件,在页面头部用js判断分辨率后动态加载定义好的样式文件

    为不同分辨率单独做样式文件,在页面头部用js判断分辨率后动态加载定义好的样式文件.样式文件命名格式如:forms[_屏幕宽度].css,样式文件中只需重新定义文本框和下拉框的宽度即可. 在包含的头文件 ...

  5. Vue mint ui用在消息页面上拉加载下拉刷新loadmore 标记

    之前总结过一个页面存在多个下拉加载的处理方式,今天再来说一下在消息页面的上拉加载和下拉刷新,基本上每个app都会有消息页面,会遇到这个需求 需求:每次加载十条数据,上拉加载下拉刷新,并且没有点击查看过 ...

  6. mysql_connect() 不支持 请检查 mysql 模块是否正确加载

    php的扩展 没有配置好! 打开php.ini文件: 搜索pdo_mysql和curl ;extension=php_curl.dll ;extension=pdo_mysql.dll 然后把2者前面 ...

  7. 页面性能优化-原生JS实现图片懒加载

    在项目开发中,我们往往会遇到一个页面需要加载很多图片的情况.我们可以一次性加载全部的图片,但是考虑到用户有可能只浏览部分图片.所以我们需要对图片加载进行优化,只加载浏览器窗口内的图片,当用户滚动时,再 ...

  8. iOS 设计 用户为王 - 关于征询授权、注册及加载等待的体验优化

    你要做的东西一定要是你无比渴望这世界上能出现的东西,这股热情和能量将会融入到你的应用中,成为它腾飞的初速度,为你带来积极反馈.把自己当做app最重要的用户,这一点非常重要. http://www.co ...

  9. ios中自定义tableView,CollectionView的cell什么时候用nib加载,什么时候用标识重用

    做了一段时间的iOS,在菜鸟的路上还有很长的路要走,把遇到的问题记下来,好记性不如烂笔头. 在项目开发中大家经常会用到tableView和collectionView两个控件,然而在cell的自定义上 ...

随机推荐

  1. SSE图像算法优化系列十二:多尺度的图像细节提升。

    无意中浏览一篇文章,中间提到了基于多尺度的图像的细节提升算法,尝试了一下,还是有一定的效果的,结合最近一直研究的SSE优化,把算法的步骤和优化过程分享给大家. 论文的全名是DARK IMAGE ENH ...

  2. struts2对于处理JSON的配置

    由于最近几年日益流行前后端分离模式,JSON作为数据载体也变得不可或缺.几乎所有的web框架都需要支持JSON,下面咱就一起了解下struts2是如何支持JSON的. 对于JSON的发送 这里有两种方 ...

  3. 《Android源码设计模式》学习笔记之ImageLoader

    微信公众号:CodingAndroid cnblog:http://www.cnblogs.com/angel88/ CSDN:http://blog.csdn.net/xinpengfei521 需 ...

  4. Servlet之初始化参数和传递数据(ServletConfig,ServletContext )

    ServletConfig 容器初始化一个Servlet的时候,会为这个Servlet建一个唯一的Servletconfig的对象(Servlet的配置对象) 容器会从部署的描述文件(web.xml) ...

  5. 大道至简第一章Java伪代码读后感

    import.java.大道至简.*; //周爱民 import.java.读后感*; public class shawanyia { //1. 编程的精义 while(山没有消失) {if(愚公没 ...

  6. cmd 更改计算机名

    bat  更改计算机名 不用重启电脑就生效^_^ @Echo off Color 0A title --更改计算机名 :A cls echo. echo. [0]退出 echo. echo. 不用重启 ...

  7. MYSQL瓶颈

    一般来说, 在使用的时候 性能从某个数值开始.突然大大下降,说明就到了瓶颈期. mysql 瓶颈有2种,一种是 cpu瓶颈  一种是 io瓶颈.cpu瓶颈多是由io引起. 而io可以通过  show ...

  8. Linux下编译memecaced

        安装memecached的时候要先把依赖的软件全部的安装上! 第一步: 在limux编译memcached需要 :yum install gcc make libtool autoconf 着 ...

  9. SQL Server学习之路(八):扩展SQL语句

    0.目录 1.问题描述 2.第一种方法 通过GROUP BY子句解决 3.第二种方法 通过聚合函数解决 4.第三种方法 在select...from...中的from后面嵌套一个表 5.第四种方法 在 ...

  10. [Bootstrap 源码]——bootstrap源码之初始化

    bootstrap源码之初始化 我们先来分析normalize.less编译后的源码,我们知道normalize.css是一个专门将不同浏览器的默认css特性设置为统一效果的css库,它和reset. ...