autolayout收集,适配,自动布局 状态栏 applicationFrame

[[UIScreen mainScreen] bounds]和 applicationFrame

bounds就是屏幕的全部区域,applicationFrame就是app显示的区域,不包含状态栏(高度20,如果状态栏隐藏的话,那么,这个结果就和bounds一样了)

 史上比较用心的纯代码实现 AutoLayout

*** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 

 1.  在AppDelegate里面添加这个方法就OK了
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_6_0 
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskAll;
}
#endif

  如果程序不是只支持横屏,而是横屏竖屏都支持的,那么就 到1 就可以解决了。但是,如果程序只支持横屏,这个解决方法就会导致一个问题:

  所有的界面都可以支持竖屏了,这个不是我们想要的,那么就需要添加下面的步骤。

Xcode 支持方向 - Upside Down

IPad 默认是UIInterfaceorientationMaskAll , IPhone 默认是 UIInterfaceOrientationMaskAllButUpsideDown

详解iOS开发中处理屏幕旋转的几种方法

在之前我们可以重写如下方法来处理屏幕旋转,但是在iOS8被弃用了

//将要旋转
override func willRotateToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval) { } // 旋转完成
override func didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation) { }
 

现在可以在控制器中重写下面的方法来处理旋转

override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) { }

iOS之屏幕旋转调用的方法

UIDeviceOrientation      是机器硬件的当前旋转方向   这个你只能取值 不能设置

UIInterfaceOrientation   是你程序界面的当前旋转方向   这个可以设置

牛B的swift屏幕旋转经验终结者(OC统一思路)

小胖说swift11-------- ios 进入某个VC强转为横屏,出VC后复原 good 4中方法

Swift与Objective-C交互

Swift-横竖屏切换

声明一个变量来判断页面是否支持横竖屏,默认情况下为0,表示不支持 
var allowRotation = 0

iOS强制转换横竖屏和键盘方向控制

OS应用中,决定键盘的方向因素在不同iOS版本中是不一样的。

  • iOS7中,键盘方向是根据状态栏方向决定的。
  • iOS8中,键盘方向是根据一个特定的window决定,打印[UIApplication sharedApplication].windows,最少有两个,第一个为UIWindow,是程序主要的keyWindow;第二个为UITextEffectsWindow,是键盘所在的window。
  • iOS9中,键盘方向由最后一层window决定,这里有点复杂,因为iOS9新增了一个UIRemoteKeyboardWindow。那么应用可能就有3个window,依次是UIWindow,UITextEffectsWindow,UIRemoteKeyboardWindow。UIRemoteKeyboardWindow成为决定键盘方向的window了,而UITextEffectsWindow控制了键盘顶部栏的方向

iOS7.0后隐藏状态栏(UIStatusBar)

重写 prefersStatusBarHidden

ios 如何隐藏状态栏 旧版的隐藏状态栏

三分钟编写一款Xcode插件

 iOS 横屏竖屏自适应总结 good  使用导航栏(wgcar)

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation

如果该viewController没有navigationController时,以下两方法可能不被调用,需要自己加入通知中心
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

获取当前屏幕方向
UIInterfaceOrientation currentOrient = [UIApplication  sharedApplication].statusBarOrientation;

iOS - layoutSubview方法的调用

layoutSubView在UIView中使用

viewcontroller 中方法 viewWillLayoutSubviews

layoutSubviews总结

[iOS] 初探 iOS8 中的 Size Class

 Swift自适应布局(Adaptive Layout)教程

 Masonry介绍与使用实践:快速上手Autolayout

Masonry教程--IOS自适配,丢掉Autolayout吧

intrinsicContentSize和Content Hugging Priority

 有趣的Autolayout示例2-Masonry实现 good

有趣的Autolayout示例3-Masonry实现

理解iOS 8中的Self Sizing Cells和Dynamic Type

对tableView三种计算动态行高方法的分析

AutolayoutExampleWithMasonry 很好的源码

原文地址:https://www.cnblogs.com/dqxu/p/4033371.html