是否有针对UINib的iOS 4之前替换或解决方法? [英] Is there a pre-iOS 4 replacement or workaround for UINib?

查看:114
本文介绍了是否有针对UINib的iOS 4之前替换或解决方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序具有一个tableview,其中包含一些相当复杂的tableviewcells。因此,这些单元格已在Interface Builder中设计,并在以后根据需要使用UINib进行实例化,只允许使用UINib - 从笔尖加载内容并根据需要进行实例化。

My application features a tableview which contains some rather complex tableviewcells. Therefore, these cells have been designed in Interface Builder and are instanciated later as needed using UINib which allows just that - load the content from a nib and instanciate it as needed.

但UIN​​ib仅适用于iOS 4.0及更高版本。

在我开始放弃所有3.x用户之前,有没有办法(轻松)使用iOS4之前的类重新创建我正在做的事情和方法?

But UINib is only available for iOS 4.0 and above.
Before I go ahead and abandon all the 3.x users, is there a way to (easily) recreate what I'm doing using pre-iOS4 classes and methods?

非常感谢!!

推荐答案

你可以加载使用以下内容从笔尖查看:

You can load views from a nib using the following:

NSArray* nibContents = [[NSBundle mainBundle] loadNibNamed:@"MyNibFilename" owner:self options:nil];
UITableViewCell* cell = (UITableViewCell*)[nibContents objectAtIndex:0];

请注意,您提供给 objectAtIndex的索引:由笔尖中视图的顺序决定。如果笔尖中唯一的东西是你的自定义表视图单元格,则0可能是正确的索引。

Note that the index you supply to objectAtIndex: is determined by the order of the views in the nib. If the only thing in the nib is your custom table view cell, then 0 is likely the correct index.

编辑:

记录UIKit添加到NSBundle。

It is a documented UIKit addition to NSBundle.

这篇关于是否有针对UINib的iOS 4之前替换或解决方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆