ios中html怎么横屏,IOS手机如何实现全屏,横屏,屏幕旋转

#import

@class HHLViewController;

@interface HHLAppDelegate : UIResponder

@property (strong,>

HHLViewController.h

#import

@interface HHLViewController : UIViewController

@property (retain,nonatomic) UIButton *mBtn;

@property (retain,nonatomic) UINavigationBar *myNavigationBar;

@property (retain,nonatomic) UIToolbar *myToolbar;

@end

HHLViewController.m

#import "HHLViewController.h"

@interface HHLViewController ()

@end

@implementation HHLViewController

- (void)viewDidLoad

{

[super viewDidLoad];

UIImage *pImage = [UIImage imageNamed:@"1.png"];

UIImageView *myImageView = [[UIImageView alloc]initWithImage:pImage];

//设置此项后,当myImagView的尺寸发生变化时,其中的图像比例不会改变。

myImageView.contentMode = UIViewContentModeScaleAspectFill;

//将clipsToBounds设置为NO后,超出frame以外的图像仍然可以绘制。

myImageView.clipsToBounds = NO;

//向autoresizingMask设置两常量后,将随着母体view的变化改变图像的宽度与高度

myImageView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;

[self.view addSubview:myImageView];

self.mBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];

self.mBtn.frame =CGRectMake(150, 300, 80, 40);

[self.mBtn setTitle:@"全屏" forState:UIControlStateNormal];

[self.mBtn addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:self.mBtn];

self.myNavigationBar =[[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)];

[self.view addSubview:self.myNavigationBar];

self.myToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 420, self.view.frame.size.width, 60)];

//self.myToolbar.frame.size.width = self.view.frame.size.width;

[self.view addSubview:self.myToolbar];

}

- (void)buttonPressed:(id)sender

{

self.mBtn.hidden = YES;

[[UIApplication sharedApplication] setStatusBarHidden:YES];

self.myNavigationBar.hidden = YES;

//[self.navigationController setNavigationBarHidden:YES animated:YES];

//self.tabBarController.hidesBottomBarWhenPushed = YES;

//[self.navigationController setToolbarHidden:YES];

self.myToolbar.hidden = YES;

}

//实现旋转

- (BOOL)shouldAutomaticallyForwardRotationMethods

{

return YES;

}

- (void)didReceiveMemoryWarning

{

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

- (void)dealloc

{

[_mBtn release];

[_myNavigationBar release];

[_myToolbar release];

[super dealloc];

}

@end

实现的效果下图所示:

0818b9ca8b590ca3270a3433284dd417.png

点击button后效果如下图所示:

0818b9ca8b590ca3270a3433284dd417.png

简单的分享就到这里,下一篇我会给大家分享一下通过手势来实现全屏,和取消全屏。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值