iOS Xib文件详解
来源:互联网 发布:尚科博文 python 编辑:程序博客网 时间:2024/04/27 23:58
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/#//apple_ref/occ/instp/UIViewController/nibName
用xib这种方式是需要加载xib文件的。加载xib文件有两种方法:// 第一种方法(较为常用)CYLView *view = [[[NSBundle mainBundle] loadNibNamed:@"CYLView" owner:nil options:nil] firstObject]; // CYLView代表CYLView.xib,代表CYLView这个类对应的xib文件。这个方法返回的是一个NSArray,我们取第一个Object或最后一个(因为这个数组只有一个CYLView没有其他对象)就是需要加载的CYLView。// 第二种方法UINib *nib = [UINib nibWithNibName:@"CYLView" bundle:nil];NSArray *objectArray = [nib instantiateWithOwner:nil options:nil];CYLView *view = [objectArray firstObject];
For more information about how the system determines which view controllers to preserve and restore, seeApp Programming Guide for iOS.
Configuring a View Controller Using Nib Files
- initWithNibName:bundle:
Designated InitializernibName
PropertyThe name of the view controller'€™s nib file, if one was specified. (read-only)
Declaration
OBJECTIVE-C
@property(nonatomic, readonly, copy) NSString *nibName
Discussion
This property contains the value specified at initialization time to the
initWithNibName:bundle:
method. The value of this property may benil
.If you use a nib file to store your view controller'€™s view, it is recommended that you specify that nib file explicitly when initializing your view controller. However, if you do not specify a nib name, and do not override the
loadView
method in your custom subclass, the view controller searches for a nib file using other means. Specifically, it looks for a nib file with an appropriate name (without the.nib
extension) and loads that nib file whenever its view is requested. Specifically, it looks (in order) for a nib file with one of the following names:If the view controller class name ends with the word ‘Controller’, as in
MyViewController
, it looks for a nib file whose name matches the class name without the word ‘€œController’, as inMyView.nib
.It looks for a nib file whose name matches the name of the view controller class. For example, if the class name is
MyViewController
, it looks for aMyViewController.nib
file.
NOTE
Nib names that include a platform-specific identifier such as
~iphone
or~ipad
are loaded only on a device of the corresponding type. For example, a nib name ofMyViewController~ipad.nib
is loaded only on iPad. If your app supports both platform types, you must provide versions of your nib files for each platform.Availability
Available in iOS 2.0 and later.
See Also
– initWithNibName:bundle:
nibBundle
nibBundle
Property
Interacting with Storyboards and Segues
storyboard
Property- shouldPerformSegueWithIdentifier:sender:
- prepareForSegue:sender:
- performSegueWithIdentifier:sender:
- allowedChildViewControllersForUnwindingFromSource:
- childViewControllerContainingSegueSource:
- canPerformUnwindSegueAction:fromViewController:withSender:
- unwindForSegue:towardsViewController:
- viewControllerForUnwindSegueAction:fromViewController:withSender:
(iOS 9.0)- segueForUnwindingToViewController:fromViewController:identifier:
(iOS 9.0)
Managing the View
view
Property- isViewLoaded
- loadView
- viewDidLoad
- loadViewIfNeeded
viewIfLoaded
Propertytitle
PropertypreferredContentSize
Property
Presenting View Controllers
modalPresentationStyle
PropertymodalTransitionStyle
PropertymodalInPopover
Property- showViewController:sender:
- showDetailViewController:sender:
- presentViewController:animated:completion:
- dismissViewControllerAnimated:completion:
definesPresentationContext
PropertyprovidesPresentationContextTransitionStyle
Property- disablesAutomaticKeyboardDismissal
Supporting Custom Transitions and Presentations
transitioningDelegate
Property- transitionCoordinator
- targetViewControllerForAction:sender:
presentationController
PropertypopoverPresentationController
Property
Responding to View Events
- viewWillAppear:
- viewDidAppear:
- viewWillDisappear:
- viewDidDisappear:
Configuring the View’s Layout Behavior
- viewWillLayoutSubviews
- viewDidLayoutSubviews
- updateViewConstraints
bottomLayoutGuide
PropertytopLayoutGuide
PropertyedgesForExtendedLayout
PropertyextendedLayoutIncludesOpaqueBars
PropertyautomaticallyAdjustsScrollViewInsets
Property
Testing for Specific Kinds of View Transitions
- isMovingFromParentViewController
- isMovingToParentViewController
- isBeingPresented
- isBeingDismissed
Configuring the View Rotation Settings
- shouldAutorotate
- supportedInterfaceOrientations
- preferredInterfaceOrientationForPresentation
+ attemptRotationToDeviceOrientation
Adapting to Environment Changes
- collapseSecondaryViewController:forSplitViewController:
- separateSecondaryViewControllerForSplitViewController:
Managing Child View Controllers in a Custom Container
childViewControllers
Property- addChildViewController:
- removeFromParentViewController
- transitionFromViewController:toViewController:duration:options:animations:completion:
- shouldAutomaticallyForwardAppearanceMethods
- beginAppearanceTransition:animated:
- endAppearanceTransition
- setOverrideTraitCollection:forChildViewController:
- overrideTraitCollectionForChildViewController:
Responding to Containment Events
- willMoveToParentViewController:
- didMoveToParentViewController:
Getting Other Related View Controllers
presentingViewController
PropertypresentedViewController
PropertyparentViewController
PropertynavigationController
PropertysplitViewController
PropertytabBarController
Property
Handling Memory Warnings
- didReceiveMemoryWarning
Managing State Restoration
restorationIdentifier
PropertyrestorationClass
Property- encodeRestorableStateWithCoder:
- decodeRestorableStateWithCoder:
- applicationFinishedRestoringState
Supporting App Extensions
extensionContext
Property
Working With 3D Touch Previews and Preview Quick Actions
The methods in this task group are available on devices that support 3D Touch. The end-user terminology for the views presented during the phases of force-based touches includes peek and pop. For clarity here, and to align with the API names, this document uses the corresponding terms preview and commit view. To learn more about 3D Touch, read Adopting 3D Touch on iPhone.
- registerForPreviewingWithDelegate:sourceView:
- unregisterForPreviewingWithContext:
- previewActionItems
Managing the Status Bar
- childViewControllerForStatusBarHidden
- childViewControllerForStatusBarStyle
- preferredStatusBarStyle
- prefersStatusBarHidden
modalPresentationCapturesStatusBarAppearance
Property- preferredStatusBarUpdateAnimation
- setNeedsStatusBarAppearanceUpdate
Configuring a Navigation Interface
navigationItem
PropertyhidesBottomBarWhenPushed
Property- setToolbarItems:animated:
toolbarItems
Property
Configuring Tab Bar Items
tabBarItem
Property
Adding Editing Behaviors to Your View Controller
editing
Property- setEditing:animated:
- editButtonItem
Accessing the Available Key Commands
- addKeyCommand:
- removeKeyCommand:
Managing Banner Ads
canDisplayBannerAds
PropertyoriginalContentView
Property
Determining Whether the View Controller is Displaying an Ad
presentingFullScreenAd
PropertydisplayingBannerAd
Property
Managing Interstitial Ads
+ prepareInterstitialAds
interstitialPresentationPolicy
Property- requestInterstitialAdPresentation
- shouldPresentInterstitialAd
Deprecated
- viewWillUnload
(iOS 6.0)- viewDidUnload
(iOS 6.0)contentSizeForViewInPopover
(iOS 7.0) Property- presentModalViewController:animated:
(iOS 6.0)- dismissModalViewControllerAnimated:
(iOS 6.0)wantsFullScreenLayout
(iOS 7.0) Property- shouldAutorotateToInterfaceOrientation:
(iOS 6.0)- rotatingHeaderView
(iOS 8.0)- rotatingFooterView
(iOS 8.0)interfaceOrientation
(iOS 8.0) Property- willRotateToInterfaceOrientation:duration:
(iOS 8.0)- willAnimateRotationToInterfaceOrientation:duration:
(iOS 8.0)- didRotateFromInterfaceOrientation:
(iOS 8.0)- willAnimateFirstHalfOfRotationToInterfaceOrientation:duration:
(iOS 5.0)- didAnimateFirstHalfOfRotationToInterfaceOrientation:
(iOS 5.0)- willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration:
(iOS 5.0)searchDisplayController
(iOS 8.0) PropertymodalViewController
(iOS 6.0) Property- shouldAutomaticallyForwardRotationMethods
(iOS 8.0)- automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers
(iOS 6.0)- presentMoviePlayerViewControllerAnimated:
(iOS 9.0)- dismissMoviePlayerViewControllerAnimated
(iOS 9.0)
Constants
UIModalPresentationStyle
UIModalTransitionStyle
ADInterstitialPresentationPolicy
Exceptions
Notifications
UIViewControllerShowDetailTargetDidChangeNotification
- iOS Xib文件详解
- ios xib文件加载xib
- iOS 加载xib文件
- ios xib文件使用
- iOS单独创建xib详解
- IOS xib,文件加载笔记
- iOS之注册xib文件
- IOS开发-读取xib文件
- iOS xib文件特别卡巨慢
- 【iOS】iOS之UIView关联xib文件
- IOS Xib使用——为控制器添加Xib文件
- IOS Xib使用——为控制器添加Xib文件
- iOS回顾笔记(03) -- 自定义View的封装和xib文件的使用详解
- iOS回顾笔记(03) -- 自定义View的封装和xib文件的使用详解
- iOS回顾笔记(03) -- 自定义View的封装和xib文件的使用详解
- iOS UIViewController 和 xib 绑定 详解
- iOS UIViewController 和 xib 绑定 详解
- iOS UIViewController 和 xib 绑定 详解
- maven项目常用包
- 数据库的数据类型
- 反射机制_提高反射效率_操作泛型_操作注解JAVA213
- 卷积神经网络LeNet Convolutional Neural Networks (LeNet)
- jquery EasyUi 登录页设计
- iOS Xib文件详解
- Spring 容器IOC的初始化过程
- Java语言特点
- Zoj 3537 Cake (DP最优三角形剖分)
- 数据库各种连接的区别
- 判断身份证:要么是15位,要么是18位,最后一位可以为字母,并写程序提出其中的年月日
- Java学习路线
- SpringMVC总结一次完整的请求
- Scala Exception