Xib的两种加载方式,与xib建立关系的两种方式
来源:互联网 发布:fpga经典书籍 知乎 编辑:程序博客网 时间:2024/05/18 06:23
@implementation JRTableViewController
- (void)viewDidLoad {
[superviewDidLoad];
self.tableView.rowHeight =90;
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 100;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
staticNSString * ID =@"JRCell";//这个ID要和xib设定的indentifier一致
JRTableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:ID ];
if (!cell) {
// 方式一,加载nib
NSArray * array = [[NSBundlemainBundle]loadNibNamed:@"JRCell"owner:niloptions:nil];
cell = [arrayfirstObject];
// 方式二,加载nib
// UINib * nib = [UINib nibWithNibName:@"JRCell" bundle:nil];
// NSArray * array = [nib instantiateWithOwner:nil options:nil];
// cell = [array firstObject];
}
// 方法一,通过tag值
// UIImageView * imageview = (UIImageView *)[cell viewWithTag:101];
// NSString * icon = [NSString stringWithFormat:@"head%i", arc4random_uniform(8)+1];
// imageview.image = [UIImage imageNamed:icon];
// 方法二,建类,连线(连线之前一定要更改xib的class)
NSString * icon = [NSStringstringWithFormat:@"head%i",arc4random_uniform(8)+1];
cell.icon.image = [UIImageimageNamed:icon];
return cell;
}
- Xib的两种加载方式,与xib建立关系的两种方式
- xib的两种加载方式
- 加载xib文件的两种方式
- iOS 加载xib的两种方式
- 加载cell的xib的两种方式
- xib自定义view的两种方式
- iOS 使用xib创建cell的两种初始化方式
- iOS xib文件引入的两种方式
- iOS加载xib的两种方法
- 加载xib的两种方法
- ios UI加载xib文件到控制器的两种方式(MS)
- 加载Xib两种方法
- 模型和自定义控件的两种方式(代码和xib)
- xcode中获取xib或者storyboard中控件 的两种方式
- 两种方式(xib和代码)创建自定义collectionview
- 从Xib文件加载UIView的5种方式
- 通过xib加载UITableViewCell的新方式
- 通过xib加载UITableViewCell的新方式
- IP地址判断有效性
- c#的List
- 第六章
- 149Max Points on a Line
- 第12周项目3-日期时间类
- Xib的两种加载方式,与xib建立关系的两种方式
- Set集合
- 十一周——继承与派生——项目四 圆的关系
- javaNIO原理(含代码)及与 同步阻塞IO 、伪异步IO比较
- 在HQL中使用单个的模糊查询,以及对于多个查询条件进行查询的话
- Layout_weight属性完全解析与使用ListView来实现表格
- 算法如何学
- 【PHP】PHP5.4.0版本ChangeLog详解(上)
- 给JavaScript初学者的24条最佳实践 译