自定义tableviewcell但是给cell里的label赋值后还是nil
1个回答
2015-07-20 · 知道合伙人软件行家
关注
展开全部
这个是自定义的cell。label是在xib里创衡锋建的
@interface MapTableCell : UITableViewCell{
UILabel *poiNO;
UILabel *poiName;
UILabel *poiAddress;
UIImageView *poiImageView;
}
@property (nonatomic ,retain) IBOutlet UILabel *poiNO;
@property (nonatomic ,retain) IBOutlet UILabel *poiName;
@property (nonatomic ,retain) IBOutlet UILabel *poiAddress;
@property (nonatomic ,retain) IBOutlet UIImageView *poiImageView;
@end
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellWithIdentifier = @"TableCellIdentifier";
MapTableCell *cell = (MapTableCell *)[tableView dequeueReusableCellWithIdentifier:CellWithIdentifier];
if (cell == nil) {
cell = [[MapTableCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellWithIdentifier];
}
NSUInteger row = [indexPath row];
BMKPoiInfo *info = [_poiInfoList objectAtIndex:row];
cell.poiName.text = [NSString stringWithFormat:@"%lu%@",(unsigned long)row,info.name];
cell.poiAddress.text = [info.city stringByAppendingString:info.address];
return cell;
}
希望能帮到你,如果满意,咐尺晌请记得采纳哦困旦~~~
@interface MapTableCell : UITableViewCell{
UILabel *poiNO;
UILabel *poiName;
UILabel *poiAddress;
UIImageView *poiImageView;
}
@property (nonatomic ,retain) IBOutlet UILabel *poiNO;
@property (nonatomic ,retain) IBOutlet UILabel *poiName;
@property (nonatomic ,retain) IBOutlet UILabel *poiAddress;
@property (nonatomic ,retain) IBOutlet UIImageView *poiImageView;
@end
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellWithIdentifier = @"TableCellIdentifier";
MapTableCell *cell = (MapTableCell *)[tableView dequeueReusableCellWithIdentifier:CellWithIdentifier];
if (cell == nil) {
cell = [[MapTableCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellWithIdentifier];
}
NSUInteger row = [indexPath row];
BMKPoiInfo *info = [_poiInfoList objectAtIndex:row];
cell.poiName.text = [NSString stringWithFormat:@"%lu%@",(unsigned long)row,info.name];
cell.poiAddress.text = [info.city stringByAppendingString:info.address];
return cell;
}
希望能帮到你,如果满意,咐尺晌请记得采纳哦困旦~~~
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询