在UITableViewCell中添加图像作为附件视图未显示

时间:2013-03-20 10:07:02

标签: ios objective-c uitableview uiimageview

我正在尝试在UITableViewCell中添加一些标签和图像作为附件视图。 但它没有在表格单元格中显示我的代码

unsigned int flags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit | NSWeekdayCalendarUnit;
NSDateComponents* parts = [[NSCalendar currentCalendar] components:flags fromDate:[NSDate date]];

UILabel *lbTime = [[UILabel alloc]initWithFrame:CGRectMake(-80, -21, 99, 20)];
[lbTime setBackgroundColor:[UIColor clearColor]];
[lbTime setTextColor:[UIColor grayColor]];
[lbTime setFont:[UIFont systemFontOfSize:13]];
int hour = parts.hour;
NSString *amPm = @"Am";
if (hour>12) {
    hour = hour -12;
    amPm = @"Pm";
}
lbTime.text = [NSString stringWithFormat:@"%.02d:%.02d %@",hour,parts.minute,amPm];


UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 15, 15)];
imgView.image = [UIImage imageNamed:@"imgWhiteAero.png"];
cell.accessoryView = imgView;


UIView *view = [[UIView alloc]init];
[view addSubview:lbTime];
[view addSubview:imgView];
cell.accessoryView = view;
[view release];
[imgView release];

标签显示成功但图像不显示 当我只添加图像作为附件视图时,它变得可见     cell.accessoryView = imgView;

但是当我在像上面提到的代码的UIView中添加它时,它没有显示

0 个答案:

没有答案