多个UIViewController中复用NIB文件
来源:互联网 发布:linux curl post 参数 编辑:程序博客网 时间:2024/05/22 16:03
- // UIView+NIB.h
- @interface UIView (NIB)
- + (id)loadFromNIB;
- @end
- // UIView+NIB.m
- #import "UIView+NIB.h"
- @implementation UIView (NIB)
- + (NSString*)nibName {
- return [self description];
- }
- + (id)loadFromNIB {
- Class klass = [self class];
- NSString *nibName = [self nibName];
- NSArray* objects = [[NSBundle mainBundle] loadNibNamed:nibName owner:self options:nil];
- for (id object in objects) {
- if ([object isKindOfClass:klass]) {
- return object;
- }
- }
- [NSException raise:@"WrongNibFormat" format:@"Nib for '%@' must contain one UIView, and its class must be '%@'", nibName, NSStringFromClass(klass)];
- return nil;
- }
- @end
- - (id)initWithOptions:(NSDictionary *)options
- {
- if (self = [super initWithNibName:@"MessageController" bundle:nil])
- {
- // Other initializtion code here
- }
- return self;
- }
- friendNews = [[FriendNewsController alloc] initWithOptions:options];
- friendMessage = [[FriendMessageController alloc] initWithOptions:options];
- sysMessage = [[SystemMessageController alloc] initWithOptions:options];
0 0
- 多个UIViewController中复用NIB文件
- 关于多个viewcontroller和nib文件旋转的问题
- iOS一个类可以关联多个nib文件
- UIViewController XIB/NIB加载过程
- Nib文件
- Nib文件
- Nib文件
- 多视图应用程序-使用多个nib
- UITableViewCell 和 nib 文件
- NIB文件的基础知识
- 什么是Nib文件
- 什么是Nib文件
- 如何打开Nib文件
- Xcode 之nib文件
- 如何打开Nib文件
- xib(nib)文件
- 什么是Nib文件
- nib文件笔记
- C# Managed DirectX 背面剔除
- android的filter
- 算法导论 - 归并排序的 C 语言实现
- 理解gamma校正
- Asterisk CALL文件使用说明
- 多个UIViewController中复用NIB文件
- 线程同步(VC_Win32)
- python学习:counter计数
- 如何不绑定脚本且不继承MonoBehaviour做U3D的开发
- leetcode_2_Add Two Numbers
- USACO2.1.1 The Castle (castle)
- Asterisk 关于抢接问题
- 记录在2015-01-27
- TiledMap出现小白线