UIViewController类详解:
通过Nib文件初始化
StoryBoard相关
copy
Unwindsegue的实现原理请参考相关文章 View相关跳转相关copy
println("view=\(view)")
- println("viewisloaded=\(isViewLoaded())")
- title="ViewController"<prename="code"class="objc">//如果不是nib文件初始化而来,初始化的时候需要调用这个方法初始化view,此方法不能主动调用,是系统调用的<prename="code"class="objc">overridefuncloadView(){
- super.loadView()<prename="code"class="objc">}//view初始化以后调用
copyoverridefuncviewDidLoad(){
copysuper.viewDidLoad()<spanstyle="font-family:Arial,sans-serif;">//view将可见的时候调用</span>
配置View的layout- }<prename="code"class="objc">overridefuncviewWillAppear(animated:Bool){
- super.viewWillAppear(animated)
- //view变得完全可见了以后执行
- overridefuncviewDidAppear(animated:Bool){
- super.viewDidAppear(animated)
- }
- //view被遮挡或者隐藏时调用
- overridefuncviewWillDisappear(animated:Bool){
- super.viewWillDisappear(animated)
- //view被遮挡或者隐藏后调用
- overridefuncviewDidDisappear(animated:Bool){
- super.viewDidDisappear(animated)
- 模式跳转
copy
//设置模式跳转的类别,但是必须是目的Controller设置,不能是上级设置
- //CoverVertical,FlipHorizontal,CrossDissolve,PartialCurl四种类型
- viewController.modalTransitionStyle=.FlipHorizontal
- //设置模式展示样式,适合于iPad上
- viewController.modalPresentationStyle=.FullScreen
- //如果展示不是.FullScreen,那么设置是不是捕获statusBar的样式,适合iPad
- viewController.modalPresentationCapturesStatusBarAppearance=//判断在模式跳转时消失是否键盘
- viewController.disablesAutomaticKeyboardDismissal()
- presentViewController(viewController,0); background-color:inherit">animated:true){()->Voidin
- //跳转到下个界面
- dismissViewControllerAnimated(true,0); background-color:inherit">completion:{()->Voidin
- //回复模式跳转
- })
copy//layoutSubviews方法调用之前
updateViewConstraints()- overridefuncviewWillLayoutSubviews(){
- super.viewWillLayoutSubviews()
- //layoutSubviews方法调用之后
- overridefuncviewDidLayoutSubviews(){
- super.viewDidLayoutSubviews()
- class="objc">
copy//延伸的方向--setwhichsidesofyourviewcanbeextendedtocoverthewholescreen.
- ifself.respondsToSelector(Selector("edgesForExtendedLayout")){
- self.edgesForExtendedLayout=.None
- //Scrollview滚动时处于全屏,默认YES
- self.respondsToSelector(Selector("automaticallyAdjustsScrollViewInsets")){
- self.automaticallyAdjustsScrollViewInsets=//当statusbar是透明时,是否扩展至StatusBar,默认情况下是NO,且statusbar不是透明的
- self.respondsToSelector(Selector("extendedLayoutIncludesOpaqueBars")){
- self.extendedLayoutIncludesOpaqueBars=false
- //控制view的大小UIPopoverController用的比较的广泛
- self.preferredContentSize=self.view.bounds.size
StatusBar相关