UIViewController详解--Swift版本

UIViewController详解--Swift版本,第1张

概述UIViewController类详解: 通过Nib文件初始化 [objc]  view plain  copy init(nibName nibName: String?, bundle nibBundle: NSBundle?)   println("nibName = \(self.nibName)")                                    //nibName

UIVIEwController类详解:

通过Nib文件初始化

[objc] view plain copy init(nibnamenibname:String?,bundlenibBundle:NSBundle?) println("nibname=\(self.nibname)")//nibname println("nibBundle=\(self.nibBundle)")//nibBundle

 StoryBoard相关  

copy println("storyboard=\(self.storyboard)")//storyboard<prename="code">//在跳转之前对Segue进行判断,如果返回false则不之行这个Segue的跳转,performSegueWithIDentifIEr:sender:如果使用了,则这个方法无效 @H_502_99@ overrIDefuncshouldPerformSegueWithIDentifIEr(IDentifIEr:String?,sender:AnyObject?)->Bool{ returntrue @H_502_99@ } //跳转执行 @H_502_99@ overrIDefuncprepareForSegue(segue:UIStoryboardSegue,0); background-color:inherit">sender:AnyObject?){ print("prepareForSegue") //根据UIStoryBoarSegue的IDentifIEr进行跳转 @H_502_99@ overrIDefuncperformSegueWithIDentifIEr(IDentifIEr:String?,153); Font-weight:bold; background-color:inherit">super.performSegueWithIDentifIEr(IDentifIEr!,sender:sender) @H_502_99@ } copy //subVIEwController是否能够执行UnwindSegue @H_502_99@ overrIDefunccanPerformUnwindSegueAction(action:Selector,0); background-color:inherit">fromVIEwController:UIVIEwController,withSendersender:AnyObject)->Bool{ } copy //如果执行UnwindSegue,就返回Segue @H_502_99@ overrIDefuncsegueForUnwindingToVIEwController(toVIEwController:UIVIEwController,0); background-color:inherit">IDentifIEr:String?)->UIStoryboardSegue{ copy //能够执行Segue的Controller @H_502_99@ funcvIEwControllerForUnwindSegueAction(action:Selector,0); background-color:inherit">sender:AnyObject?)->UIVIEwController?{ }

 

 Unwindsegue的实现原理请参考相关文章  VIEw相关

copy println("vIEw=\(vIEw)") @H_502_99@ println("vIEwisloaded=\(isVIEwLoaded())") Title="VIEwController"<prename="code"class="objc">//如果不是nib文件初始化而来,初始化的时候需要调用这个方法初始化vIEw,此方法不能主动调用,是系统调用的<prename="code">overrIDefuncloadVIEw(){ @H_502_99@ super.loadVIEw()<prename="code"class="objc">}//vIEw初始化以后调用 copy overrIDefuncvIEwDIDLoad(){ copy super.vIEwDIDLoad()<spanstyle="Font-family:Arial,sans-serif;">//vIEw将可见的时候调用</span> @H_502_99@ }<prename="code"class="objc">overrIDefuncvIEwWillAppear(animated:Bool){ super.vIEwWillAppear(animated) @H_502_99@ //vIEw变得完全可见了以后执行 overrIDefuncvIEwDIDAppear(animated:Bool){ super.vIEwDIDAppear(animated) } @H_502_99@ //vIEw被遮挡或者隐藏时调用 @H_502_99@ 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 //回复模式跳转 }) 配置VIEw的layout
copy //layoutSubvIEws方法调用之前 @H_502_99@ overrIDefuncvIEwWillLayoutSubvIEws(){ super.vIEwWillLayoutSubvIEws() //layoutSubvIEws方法调用之后 @H_502_99@ overrIDefuncvIEwDIDLayoutSubvIEws(){ super.vIEwDIDLayoutSubvIEws() class="objc"> updateVIEwConstraints()

 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

跳转相关 copy isBeingPresented()//是否在展示 @H_502_99@ isBeingdismissed()//是否在dismiss isMovingtoparentVIEwController() isMovingFromParentVIEwController() 旋转相关
copy //是否需要旋转 @H_502_99@ overrIDefuncshouldautorotate()->Bool{ //支持的方向 @H_502_99@ overrIDefuncsupportedInterfaceOrIEntations()->Int{ return2 //优先支持的方向 @H_502_99@ overrIDefuncpreferredInterfaceOrIEntationForPresentation()->UIInterfaceOrIEntation{ return.Portrait @H_502_99@ } 自定义的VIEwController Container copy //https://developer.apple.com/library/ios/featuredarticles/VIEwControllerPGforiPhoneOS/CreatingCustomContainerVIEwControllers/CreatingCustomContainerVIEwControllers.HTML //addChildVIEwController:调用这个方法指明一个视图控制器作为你的子视图。 funcaddChildVIEwController(childController:UIVIEwController){ //调用这个方法将一个视图控制器从你的子视图列表里移除。 funcremoveFromParentVIEwController(){ //这是一个使用一个唯一可选的视图替换另一个视图的新方法,或者移动一个子视图到前台来。通过使用这个方法,这个视图控制器的生命周期信息会被正确地发送出去funcTransitionFromVIEwController(fromVIEwController:UIVIEwController,toVIEwController:UIVIEwController,duration:NSTimeInterval,options:UIVIEwAnimationoptions,animations:()->VoID,completion:((Bool)->VoID)?){ //将要移到父Controller @H_502_99@ funcwillMovetoParentVIEwController(parent:UIVIEwController?){ //已经移到父Controller @H_502_99@ funcdIDMovetoParentVIEwController(parent:UIVIEwController?){ //触发子VIEwController的vIEwWillAppear @H_502_99@ funcbeginAppearanceTransition(isAppearing:Bool,0); background-color:inherit">animated:Bool){ //触发childd的vIEwDIDAppear这些方法 @H_502_99@ funcendAppearanceTransition(){ //childVIEwController的作为状态栏 @H_502_99@ funcchildVIEwControllerForStatusbarStyle()->UIVIEwController?{ returnnil; //childVIEwController的状态栏是否隐藏设置状态栏 @H_502_99@ funcchildVIEwControllerForStatusbarHIDden()->UIVIEwController?{ 恢复相关
copy restorationIDentifIEr恢复标示 @H_502_99@ restorationClass恢复的类 overrIDefuncencodeRestorableStateWithCoder(coder:NSCoder){ @H_502_99@ overrIDefuncdecodeRestorableStateWithCoder(coder:NSCoder){ applicationFinishedRestoringState()恢复完成 获得其他的VIEwController
copy println("parentVIEwController=\(self.parentVIEwController)")//父类Controller @H_502_99@ println("presentedVIEwController=\(self.presentedVIEwController)")//Controller模式跳转到去Controller或父容器 println("presentingVIEwController=\(self.presentingVIEwController)")//Controller模式跳转来自于Controller或父容器 //self.navigationController //self.tabbarController //self.presentationController //self.splitVIEwController //self.popoverPresentationController

Statusbar相关 copy @H_502_99@ vIEwController.modalPresentationCapturesstatusBarappearance=true //设置当前VIEwController的Statusbar的样式 @H_502_99@ overrIDefuncpreferredStatusbarStyle()->UIStatusbarStyle{ return.Default //隐藏还是展示statusbar @H_502_99@ overrIDefuncprefeRSStatusbarHIDden()->Bool{ //statusbar的改变动画 @H_502_99@ overrIDefuncpreferredStatusbarUpdateAnimation()->UIStatusBaranimation{ return.Fade //当statusbar的状态改变后需要调用刷新 //setNeedsstatusBarappearanceUpdate() Navigation相关
copy overrIDefuncsettoolbaritems(toolbaritems:[AnyObject]?,0); background-color:inherit">animated:Bool){ self.navigationItem self.editbuttonItem() @H_502_99@ hIDesBottombarWhenPushed=self.toolbaritems=nil Tabbar相关
copy self.toolbaritems 常量
copy UIModalTransitionStyle @H_502_99@ ModalPresentationStyles UIVIEwControllerHIErarchyInconsistencyException @H_502_99@ UIVIEwControllerShowDetailTargetDIDChangeNotification 总结

以上是内存溢出为你收集整理的UIViewController详解--Swift版本全部内容,希望文章能够帮你解决UIViewController详解--Swift版本所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1074073.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存