界面用xib设置好了 在使用的时候
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CustomerCell";
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
NSArray * nib = [[NSBundle mainBundle] loadNibNamed:@"MSNeedCheckCell" owner:self options:nil] ;
cell = [nib objectAtIndex:0];
}
//填充cell的内容
}
在界面滑动的时候 会感觉界面有点不流畅 请问是上面读xib的时候有问题吗?
试试从类中的初始化方法中调用下面的方法:
[self.tableView registerNib:[UINib nibWithNibName:@"MSNeedCheckCell" bundle:nil]
forCellReuseIdentifier:@"CustomerCell"];
然后,可以移除你代码中if (!cell) {
部分,因为它会一直返回cell。此方法只加载一次nib,不是每次都加载,因此会更快一些。