UITableViewCell';s IAMGEEVIEW框架

UITableViewCell';s IAMGEEVIEW框架,uitableview,uiimageview,Uitableview,Uiimageview,我试图在UITableViewCell中打印UIImageView的帧,但得到的结果是{{0,0},{0,0} - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView deq

我试图在UITableViewCell中打印UIImageView的帧,但得到的结果是{{0,0},{0,0}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    // Configure the cell...
    if(cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

        cell.textLabel.font = [UIFont fontWithName:@"Arial" size:13.0f];        
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

        //cell.imageView.frame = CGRectMake(2, 2, 38, 38);
    }

    NSString *imageName = [[itemsArr objectAtIndex:indexPath.row] objectForKey:@"image"];
    cell.imageView.image = [UIImage imageNamed:imageName];
    cell.textLabel.text = [[itemsArr objectAtIndex:indexPath.row] objectForKey:@"title"];


    NSLog(@"Image Frame : %@", NSStringFromCGRect([cell.imageView frame]));

    return cell;
}

我做错了什么?

试试这个,我在代码中添加了我的标记

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    // Configure the cell...
    if(cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

        cell.textLabel.font = [UIFont fontWithName:@"Arial" size:13.0f];        
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

        //cell.imageView.frame = CGRectMake(2, 2, 38, 38);
    }

    NSString *imageName = [[itemsArr objectAtIndex:indexPath.row] objectForKey:@"image"];
    cell.imageView.image = [UIImage imageNamed:imageName];

    /* EDITED CODE START */
    CGFloat x = cell.imageView.image.origin.x;
    CGFloat y = cell.imageView.image.origin.y;
    CGFloat width = cell.imageView.image.size.width;
    CGFloat height = cell.imageView.image.size.height;
    cell.imageView.frame = CGRectMake(x,y,width,height);
    /* EDITED CODE END */

    cell.textLabel.text = [[itemsArr objectAtIndex:indexPath.row] objectForKey:@"title"];


    NSLog(@"Image Frame : %@", NSStringFromCGRect([cell.imageView frame]));

    return cell;
}
@实现UITableViewCell(BrowseHistoryView) -(无效)布局子视图 { [超级布局子视图]; 如果(iPhone) { self.imageView.frame=CGRectMake(5,3,18.0f,18.0f); } 其他的 { self.imageView.frame=CGRectMake(10,15,18.0f,18.0f); } } @结束
仍然不起作用。我更正了以下CGFloat x=cell.imageView.image.origin.x;CGFloat y=cell.imageView.image.origin.y;到CGFloat x=cell.imageView.frame.origin.x;CGFloat y=cell.imageView.frame.origin.y;[见此] @implementation UITableViewCell (BrowseHistoryView) - (void)layoutSubviews { [super layoutSubviews]; if (isPhone) { self.imageView.frame = CGRectMake(5, 3, 18.0f, 18.0f); } else { self.imageView.frame = CGRectMake(10, 15, 18.0f, 18.0f); } } @end