解决方案 »
- Iphone首选相如何做国际化
- ios中 property 声明的变量和普通变量有什么区别
- iOS 如何进行点对点通信?
- IOS tabbar 显示在屏幕左边
- ios从数组n个元素中取出m个元素组成新的子数组 的所有组合
- 触屏点餐系统,用什么语言开发?
- uicollectionview遵守协议,但是为什么不走代理方法呢?
- 工程中添加支付宝功能报错,报了#include <openssl/asn1.h> 找不到文件等一些错误
- Object-C字符串拼接问题
- 在使用GCDAsyncSocket开发过程中怎么写一个接口实现服务端对某一个端口的绑定之后的解除绑定
- 内存泄露 软键盘输入内容上涨
- UITabBarController如何实现子页面跳转
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellWithIdentifier = @"Cell";
FYCellTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellWithIdentifier];
NSLog(@"tableViewtableViewtableView--->%d", [indexPath row]);
if (cell == nil) {
cell = [[FYCellTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellWithIdentifier];
cell.backgroundColor = [UIColor colorWithRed:236/255.0f green:232/255.0f blue:211/255.0f alpha:1.0];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
NSLog(@"cell == nil");
}
else
{
NSLog(@"cell != nil");
}
NSUInteger row = [indexPath row];
ObjectInfo valueInfo = CoreService::getSharedService()->app.getNearbyVC()[row]; NSString *name = [[NSString alloc] initWithCString:valueInfo.GetabyObjectName() encoding:NSUTF8StringEncoding];
cell.nameLabel.text = name;
CGSize nameSize = [name sizeWithFont:cell.nameLabel.font];
cell.nameLabel.frame = CGRectMake(85, 12, nameSize.width, 15);
int photoCounts = valueInfo.GetphotoCounts();
if( photoCounts > 0 ){
cell.albumImg.frame = CGRectMake(90+nameSize.width, 12, 15, 15);
cell.albumImg.hidden = NO;
}else{
cell.albumImg.hidden = YES;
} FYUtil *util = [[FYUtil alloc] init];
NSString *skillStr = [[NSString alloc] initWithFormat:@"Lv.%@",[util displayLevel:valueInfo.Getprestige()]];
[cell.skillLabel setText:skillStr]; NSString *charmStr = [[NSString alloc] initWithFormat:@"魅力 %d",valueInfo.Getcharm()];
[cell.charmLabel setText:charmStr];
if( strlen(valueInfo.GetabySignature()) == 0 ){
[cell.signatureLabel setText:@"这个人还没写个性签名!"];
}else{
NSString *signature = [[NSString alloc] initWithCString:valueInfo.GetabySignature() encoding:NSUTF8StringEncoding];
[cell.signatureLabel setText:signature];
}
int gender = valueInfo.GetGender();
if( gender == 0 ){
[cell.genderImg setImage:[UIImage imageNamed:@"GlobalMale"]];
}else if( gender == 1 ){
[cell.genderImg setImage:[UIImage imageNamed:@"GlobalFemale"]];
} NSString *distance = [[NSString alloc] initWithFormat:@"%.2fkm",valueInfo.GetDistance()];
cell.distanceLab.text = distance;
cell.distanceLab.frame = CGRectMake(0, 16, 313, 10);
cell.distanceLab.textAlignment = NSTextAlignmentRight;
FYC__ToOC *convert = [[FYC__ToOC alloc] init];
NSString *temp = [[NSString alloc] initWithString:[convert convertFaceId:valueInfo.GetabyObjectFaceId()]];
[cell egoImageViewWithImg:temp];
return cell;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{}
这个代理方法会在cell创建时被调用,也就是说有多少数据就会被调用多少次。所以说在这个代理方法内最好是只是有绑定cell元素的操作,避免出现调用其它方法来获取数据等的数据操作,因为这些操作可能会很耗时,而且又被每次执行,cell渲染慢是可想而知。
我的建议是在给uitableview的datasource中来处理。这样你只需要处理好一次datasource,在上面的代理方法中使用时就会快很多。