UIViewController
UIViewController 在MVC模式中就是C。关于MVC,可以看
UIViewController 主要具有什么功能呢?
View Management
When you define a new subclass of UIViewController, you must specify the views to be managed by the controller. A typical view hierarchy consists of a view with flexible bounds—a reference to which is available in the view (page 40) property of this class—and one or more subviews that provide the actual content.
当定义一个UIViewController时,必须指定由这个controller管理的views。一个典型的View hierarchy包含一个有fexible bounds的view,和若干个提供实际内容的subview。viewcontroller中View property就是对所管理的view的一个reference。
The size and position of the root view is usually determined by another object that owns the view controller and displays its contents. The view controller determines the positions of any subviews it owns based on the size given to its root view by the owning object.
root view的大小和位置通常由另外一个对象来决定,这个对象own 这个view controller。view controller决定subview的位置。
A view controller is usually owned by a window or another view controller. If a view controller is owned by a window object, it acts as the window’s root view controller. The view controller’s root view is added as a subview of the window and resized to fill the window. If the view controller is owned by another view controller, then the parent view controller determines when and how the
child view controller’s contents are displayed.
一个view controller通常由一个window或者另外一个view controller所拥有。如果它被window拥有,它就是Window的root view controller。view controller的root view被作为window的subview,resize并填满window。如果它被另外一个view controller拥有,父view controller决定子view controller的内容何时和如何被显示出来。
The UIViewController class provides built-in support for loading a view controller’s views whenever they are needed. Specifically, views are automatically loaded when the view property is accessed. 有几种方法可以完成view 和view controller关联的整个过程:
1. storyboard。view 和view controller都被定义在storyboard中,在运行时,viewcontroller根据storyboard中的设置自动实例化和配置它所管理的views。
At runtime, the view controller uses the storyboard to automatically instantiate and configure its views. Often, the view controller itself is automatically created by segues defined in the storyboard. When you define a view controller’s contents using a storyboard, you never directly allocate and initialize the view controller object. Instead, when you need to programmatically instantiate the view controller, you do so by calling the instantiateViewControllerWithIdentifier: method on a UIStoryboard object.
通常,我们不需要直接allocate和初始化在storyboard中的view controller,如果需要,可以使用instantiateViewControllerWithIdentifier:来完成。
2. 使用nib文件。在nib文件中,我们可以定义view controller已经view,但是不能像storyboard那样定义view controller之间的转换关系。可以调用UIViewController的initWithNibName:bundle:来初始化一个view controller。
3. programmatically way。如果不能在storyboard中或者nib文件中定义view,那就在override loadView方法, manually 实例化view hierarchy并赋值给view 属性。
这3种方法的最终结果都是一样的。
Tasks
Creating a View Controller Using Nib Files
– initWithNibName:bundle:
nibName property
nibBundle property
Using a Storyboard
– shouldPerformSegueWithIdentifier:sender:
– performSegueWithIdentifier:sender:
– prepareForSegue:sender:
storyboard property
– canPerformUnwindSegueAction:fromViewController:withSender:
– transitionCoordinator
Managing the View
view property
– isViewLoaded
– loadView
– viewDidLoad
title property
– viewDidUnload Deprecated in iOS 6.0
– viewWillUnload Deprecated in iOS 6.0
Handling Memory Warnings
– didReceiveMemoryWarning
Responding to View Events
– viewWillAppear:
– viewDidAppear:
– viewWillDisappear:
– viewDidDisappear:
– viewWillLayoutSubviews
– viewDidLayoutSubviews
Testing for Specific Kinds of View Transitions
– isMovingFromParentViewController
– isMovingToParentViewController
– isBeingPresented
– isBeingDismissed
Configuring the View’s Layout Behavior
– updateViewConstraints
automaticallyAdjustsScrollViewInsets property
bottomLayoutGuide property
topLayoutGuide property
edgesForExtendedLayout property
preferredContentSize property
extendedLayoutIncludesOpaqueBars property
– childViewControllerForStatusBarHidden
– childViewControllerForStatusBarStyle
– preferredStatusBarStyle
– prefersStatusBarHidden
modalPresentationCapturesStatusBarAppearance property
– preferredStatusBarUpdateAnimation
– setNeedsStatusBarAppearanceUpdate
wantsFullScreenLayout property Deprecated in iOS 7.0
Configuring the View Rotation Settings
– shouldAutorotate
– supportedInterfaceOrientations
– preferredInterfaceOrientationForPresentation
interfaceOrientation property
+ attemptRotationToDeviceOrientation
– rotatingHeaderView
– rotatingFooterView
– shouldAutorotateToInterfaceOrientation: Deprecated in iOS 6.0
Responding to View Rotation Events
– willRotateToInterfaceOrientation:duration:
– willAnimateRotationToInterfaceOrientation:duration:
– didRotateFromInterfaceOrientation:
– didAnimateFirstHalfOfRotationToInterfaceOrientation: Deprecated in iOS 5.0
– willAnimateFirstHalfOfRotationToInterfaceOrientation:duration: Deprecated in iOS 5.0
– willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration: Deprecated in iOS 5.0
Responding to Containment Events
– willMoveToParentViewController:
– didMoveToParentViewController:
Adding Editing Behaviors to Your View Controller
editing property
– setEditing:animated:
Managing State Restoration
restorationIdentifier property
restorationClass property
– encodeRestorableStateWithCoder:
– decodeRestorableStateWithCoder:
– applicationFinishedRestoringState
Presenting Another View Controller’s Content
– presentViewController:animated:completion:
– dismissViewControllerAnimated:completion:
modalTransitionStyle property
modalPresentationStyle property
definesPresentationContext property
transitioningDelegate property
providesPresentationContextTransitionStyle property
– disablesAutomaticKeyboardDismissal
– dismissModalViewControllerAnimated: Deprecated in iOS 6.0
– presentModalViewController:animated: Deprecated in iOS 6.0
Getting Other Related View Controllers
presentingViewController property
presentedViewController property
parentViewController property
navigationController property
splitViewController property
tabBarController property
searchDisplayController property
modalViewController property Deprecated in iOS 6.0
Managing Child View Controllers in a Custom Container
childViewControllers property
– addChildViewController:
– removeFromParentViewController
– shouldAutomaticallyForwardRotationMethods
– shouldAutomaticallyForwardAppearanceMethods
– transitionFromViewController:toViewController:duration:options:animations:completion:
– beginAppearanceTransition:animated:
– endAppearanceTransition
– viewControllerForUnwindSegueAction:fromViewController:withSender:
– segueForUnwindingToViewController:fromViewController:identifier:
– automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers Deprecated in iOS 6.0
Configuring a Navigation Interface
navigationItem property
– editButtonItem
hidesBottomBarWhenPushed property
– setToolbarItems:animated:
toolbarItems property
Configuring Tab Bar Items
tabBarItem property
Configuring Display in a Popover Controller
modalInPopover property
contentSizeForViewInPopover property Deprecated in iOS 7.0
Reference:
2.
UIViewController的更多相关文章
- UIViewController生命周期-完整版
一.UIViewController 的生命周期 下面带 (NSObject)的方法是NSObject提供的方法.其他的都是UIViewController 提供的方法. load (NSObje ...
- 拦截UIViewController的popViewController事件
实现拦截UIViewController的pop操作有两种方式: 自定义实现返回按钮,即设置UIBarButtonItem来实现自定义的返回操作. 创建UINavigatonController的Ca ...
- iOS: 在UIViewController 中添加Static UITableView
如果你直接在 UIViewController 中加入一个 UITableView 并将其 Content 属性设置为 Static Cells,此时 Xcode 会报错: Static table ...
- 8. UIViewController
1. UIViewController 的认识 UIViewController在iOS开发中占据很重要的位置,iOS的整个UI开发的核心思想也是MVC的架构,从UIViewController的命名 ...
- 从一个控制器调到另一个控制器的[UIViewController _loadViewFromNibNamed:bundle:]崩溃
一,现象和分析: 1.崩溃的主要地方是[UIViewController _loadViewFromNibNamed:bundle:] ,是从 A 控制器 push 到 B 控制器后, B 控制器的v ...
- UIViewController相关知识
title: UIViewController 相关知识date: 2015-12-13 11:50categories: IOS tags: UIViewController 小小程序猿我的博客:h ...
- [IOS基础]关于IOS的UIScreeen,UIView,UIViewController,UIWindow理解
UIScreen: 代表当前这个屏幕,通过UIApplication可以获得这个属性 UIView: 一个矩形试图,包含用户手势和时间响应 UIViewController: 一个UIView的集 ...
- info.plist、pch和四大对象(UIApplication、UIApplicationDelegate、UIWindow、UIViewController)
本文目录 1.程序配置文件info.plist,全局头文件pch 2.应用程序对象UIApplication介绍 3.UIApplicationDelegate介绍,程序启动过程 4.UIWindow ...
- 3.UIViewController详解
一. UIViewController,视图控制器,它是UIKit中非常重要的组成部分.它由控制器+View两部分组成. 控制器功能: ->实现代码逻辑,决定它自带的View的界面显示. -& ...
- UIViewController生命周期
UIViewController生命周期
随机推荐
- D3D的内存类型
一.对D3D中AGP显存.内存.显存三种内存的解释 三种内存AGP内存(非本地显存),显存(本地内存),系统内存,其中我们都知道系统内存就是咱那内存条,那这AGP内存是个啥玩意啊?其实是因为在以前显卡 ...
- 在Windows下安装64位压缩包版mysql 5.7.11版本的方法
为了学习数据库,自己去网上下载了最新版本的Windows64位的mysql 5.7.11,但是花了很长的时间在安装的问题上,同时也借鉴了几位前辈的博文来帮助自己解决在安装过程中遇到的问题,安装成功之后 ...
- Principle and Application of Database System
<数据库系统原理与应用>课程教学大纲 英文名称:Principle and Application of Database System 课程类型:专业必修课 学时/学分:48+16/3. ...
- python中列表的操作
list1 = ['A' , 'B' , 'C'] list1[0] ; list1[-1] # 取第一个和最后一个元素 list1[ : ] ; list1[ : len(list1)] # 取所有 ...
- hdu----(4513)吉哥系列故事——完美队形II(manacher(最长回文串算法))
吉哥系列故事——完美队形II Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)To ...
- 学习HTML5之新特性标签一览(详细)
HTML5又2008年诞生,HTML5大致可以等同于=html+css3+javascriptapi.... so --->支持css3强大的选择器和动画以及javascript的新的函数 先来 ...
- go——beego的数据库增删改查
一直都不理解使用go语言的时候,为什么还要自己去装beego,以为使用go便可以解决所有的问题,结果在朋友的点拨下,才意识到: go与beego的关系就好比是nodejs与thinkjs的关系,因此也 ...
- sqlserver获取表名,字段名
一.获取表的基本信息 SELECT [TableName] = [Tables].name , [TableOwner] = [Schemas].name , [TableCreateDate] = ...
- cisco VPN
配置实例:公司在北京而分公司在上海,如果租用光纤业务费用会比较高,另外安全性也没有保证,特别是对内网的访问方面.我们要在总公司和分公司之间建立有效的VPN连接.具体网络拓扑如图1所示.北京路由器名为R ...
- 智能手机Web开发笔记
智能手机版(简称M版)前端开发终于告一段落,第一次做移动端开发,没有想象中那么难搞,但是期间也遇到了各种这样那样的问题,虽然从小日记都不是自己写的,但是开发笔记还是要自己写的,不敢说让别人学习,只是仅 ...