0

我添加了一个UIImageview作为subviewUITableViewCell.contentview它在单元格的左侧和右侧有边距。旋转设备时,Autoresizing对我不起作用。我在用:

UIImageView *imgviewcellBg=[[UIImageView alloc]initWithFrame:CGRectMake(9, 3,     self.view.bounds.size.width-18, 33)];
imgviewcellBg.autoresizesSubviews=UIViewAutoresizingFlexibleWidth;
[cell.contentView addSubview:imgviewcellBg];

帮我。谢谢。

4

1 回答 1

1
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
    if(cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier]autorelease];
        cell.frame = CGRectMake(cell.frame.origin.x, cell.frame.origin.y, tblMyWines.frame.size.width, cell.frame.size.height);
    }

    UIImageView *imgviewcellBg=[[UIImageView alloc]initWithFrame:CGRectMake(tbl.frame.origin.x+5, 3, tbl.frame.size.width-10.0, 33)];
    [cell.contentView addSubview:imgviewcellBg];

    return cell;
}
于 2012-12-20T06:39:46.577 回答