zoukankan      html  css  js  c++  java
  • 如何实现ios屏幕的横竖屏自适应(转)

    如何实现ios屏幕的横竖屏自适应

    首先在UIViewController的
    -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    方法中设置设备要支持的deviceOrientation;
    在UIViewController的
    -(void)willRotateToInterfaceOrientation(UIInterfaceOrientation)toInterfaceOrientation 
    duration:(NSTimeInterval)duration
    或者
    -(void)willAnimateRotationToInterfaceOrientation(UIInterfaceOrientation)interfaceOrientation
    duration:(NSTimeInterval)duration
    重新设置所有子view的frame
     
    当UIView设置成自动适配屏幕(即myView.autoresizesSubviews = YES)时,当我们重新设置myView的frame时(一般屏幕旋转时我们都会重新设置view的frame),会自动调用 layoutSubviers方法,我们可以在该方法中判断屏幕的方向,并调整各子view的frame。
     
    如果工层中有一个superViewController,然后在该控制器的试图上加上了另一个subViewController的 view,无论如何subViewController的以上三个方法都不会被调用,这个时候,可以在superViewController的
    -(void)willRotateToInterfaceOrientation(UIInterfaceOrientation)toInterfaceOrientation 
    duration:(NSTimeInterval)duration
    或者
    -(void)willAnimateRotationToInterfaceOrientation(UIInterfaceOrientation)interfaceOrientation
    duration:(NSTimeInterval)duration
    方法中重新配置subViewController的view。
  • 相关阅读:
    nvidia-smi电源显示ERR (Pwr:Usage ERR)
    阿里云windows安装ftp
    ansible常用模块
    ansible playbook
    ansible Inventory
    ansible安装
    ansible命令
    ansible配置文件
    js插件中提示框含有 或者<br/>显示不成换行怎么办,改样式
    [转] react项目安装及运行
  • 原文地址:https://www.cnblogs.com/yaoliang11/p/2810988.html
Copyright © 2011-2022 走看看