опробуйте этот код, я решил
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//[tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
static NSString *CellIdentifier = @"Cell";
HJManagedImageV* mi;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
mi = [[[HJManagedImageV alloc] initWithFrame:CGRectMake(-18,-2,90,90)] autorelease];
mi.tag = 999;
[cell addSubview:mi];
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
CGSize sizeTitle = [[self.story objectAtIndex:indexPath.row] sizeWithFont:[UIFont boldSystemFontOfSize:16.0]
constrainedToSize:CGSizeMake(200, 40)
lineBreakMode:UILineBreakModeWordWrap];
float width = sizeTitle.width;
NSLog(@"Width %f", width);
width = width+15;
NSDictionary *boy=[self.media1 objectAtIndex:indexPath.row];
NSString *str=[[NSString alloc]initWithFormat:@"%@",boy];
NSInteger n=[str intValue];
NSLog(@"the value:%@",str);
CGRect coreFrame;
if(width<170){
coreFrame = CGRectMake(2, 6, width, 40);
}
else{
coreFrame = CGRectMake(2, 6, 170, 40);
width = 175;
}
float k = width+85;
UILabel *lab = [[UILabel alloc] initWithFrame:coreFrame];
lab.text = [self.story objectAtIndex:indexPath.row];
[cell.contentView addSubview:lab];
if(n ==0)
{
CGRect starFrame = CGRectMake(width,6, 85, 37);
UIImageView *starImage = [[[UIImageView alloc] initWithFrame:starFrame] autorelease];
starImage.image = [UIImage imageNamed:@"nostar.png"];
starImage.backgroundColor=[UIColor clearColor];
[cell.contentView addSubview:starImage];
NSString *boo=[[NSString alloc]initWithFormat:@"%d",n];
NSString *str=[[NSString alloc]initWithFormat:@"(%@)",boo];
// str=[str substringToIndex:4];
CGRect labelFrame = CGRectMake(k,6, 40, 40);
UILabel *Label = [[[UILabel alloc] initWithFrame:labelFrame] autorelease];
Label.text=str;
Label.tag=1000;
Label.textColor=[UIColor grayColor];
[cell.contentView addSubview:Label];
}
if(n >=1)
{
CGRect starFrame = CGRectMake(width,6, 85, 37);
UIImageView *starImage = [[[UIImageView alloc] initWithFrame:starFrame] autorelease];
starImage.image = [UIImage imageNamed:@"1star.png"];
[cell.contentView addSubview:starImage];
NSString *boo=[[NSString alloc]initWithFormat:@"%d",n];
CGRect labelFrame = CGRectMake(k,6, 40, 40);
UILabel *Label = [[[UILabel alloc] initWithFrame:labelFrame] autorelease];
NSString *str=[[NSString alloc]initWithFormat:@"(%@)",boo];
Label.text=str;
Label.tag=1000;
Label.textColor=[UIColor grayColor];
[cell.contentView addSubview:Label];
}
if(n >=2)
{
CGRect starFrame = CGRectMake(width,6, 85, 37);
UIImageView *starImage = [[[UIImageView alloc] initWithFrame:starFrame] autorelease];
starImage.image = [UIImage imageNamed:@"twostar.png"];
[cell.contentView addSubview:starImage];
NSString *boo=[[NSString alloc]initWithFormat:@"%d",n];
NSString *str=[[NSString alloc]initWithFormat:@"(%@)",boo];
CGRect labelFrame = CGRectMake(k,6, 40,40);
UILabel *Label = [[[UILabel alloc] initWithFrame:labelFrame] autorelease];
Label.text=str;
Label.tag=1000;
Label.textColor=[UIColor grayColor];
// Label.backgroundColor=[UIColor clearColor];
[cell.contentView addSubview:Label];
}
if(n >=3)
{
CGRect starFrame = CGRectMake(width,6, 85, 37);
UIImageView *starImage = [[[UIImageView alloc] initWithFrame:starFrame] autorelease];
starImage.image = [UIImage imageNamed:@"threestar.png"];
[cell.contentView addSubview:starImage];
NSString *boo=[[NSString alloc]initWithFormat:@"%d",n];
NSString *str=[[NSString alloc]initWithFormat:@"(%@)",boo];
// str=[str substringToIndex:4];
CGRect labelFrame = CGRectMake(k,6, 40,40);
UILabel *Label = [[[UILabel alloc] initWithFrame:labelFrame] autorelease];
Label.text=str;
Label.tag=1000;
Label.textColor=[UIColor grayColor];
[cell.contentView addSubview:Label];
}
if(n >= 4)
{
CGRect starFrame = CGRectMake(width,6, 85, 37);
UIImageView *starImage = [[[UIImageView alloc] initWithFrame:starFrame] autorelease];
starImage.image = [UIImage imageNamed:@"4star.png"];
[cell.contentView addSubview:starImage];
NSString *boo=[[NSString alloc]initWithFormat:@"%d",n];
NSString *str=[[NSString alloc]initWithFormat:@"(%@)",boo];
//str=[str substringToIndex:4];
CGRect labelFrame = CGRectMake(k,6,40,40);
UILabel *Label = [[[UILabel alloc] initWithFrame:labelFrame] autorelease];
Label.text=str;
Label.tag=1000;
Label.textColor=[UIColor grayColor];
//Label.backgroundColor=[UIColor clearColor];
[cell.contentView addSubview:Label];
}
if(n >= 5)
{
CGRect starFrame = CGRectMake(width,6, 85, 37);
UIImageView *starImage = [[[UIImageView alloc] initWithFrame:starFrame] autorelease];
starImage.image = [UIImage imageNamed:@"5star.png"];
[cell.contentView addSubview:starImage];
NSString *boo=[[NSString alloc]initWithFormat:@"%d",n];
NSString *str=[[NSString alloc]initWithFormat:@"(%@)",boo];
// str=[str substringToIndex:4];
CGRect labelFrame = CGRectMake(k,6, 40,40);
UILabel *Label = [[[UILabel alloc] initWithFrame:labelFrame] autorelease];
Label.font = [UIFont systemFontOfSize:18];
Label.text=str;
Label.tag=1000;
Label.textColor=[UIColor grayColor];
// Label.backgroundColor=[UIColor clearColor];
[cell.contentView addSubview:Label];
}
return cell;
}