Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableView单元格Imageview是否在单击时更改其大小?_Ios_Objective C_Image_Uitableview - Fatal编程技术网

Ios UITableView单元格Imageview是否在单击时更改其大小?

Ios UITableView单元格Imageview是否在单击时更改其大小?,ios,objective-c,image,uitableview,Ios,Objective C,Image,Uitableview,当我加载页面时,请检查下图 当我点击一行时,相应的图像会以不同的大小显示,请检查下面的图像(当我点击第一行和第二行时) 请帮我解决这个问题。这里我使用SDWebImage从url延迟加载图像 我的代码: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; //count of section } - (NSInteger)tableView:(UITableView *)

当我加载页面时,请检查下图

当我点击一行时,相应的图像会以不同的大小显示,请检查下面的图像(当我点击第一行和第二行时)

请帮我解决这个问题。这里我使用SDWebImage从url延迟加载图像

我的代码:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;    //count of section
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return [names count];    //count number of row from counting array hear cataGorry is An Array
}



- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *MyIdentifier = @"service";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];

    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                       reuseIdentifier:MyIdentifier]
        ;
    }

    // Here we use the provided setImageWithURL: method to load the web image
    // Ensure you use a placeholder image otherwise cells will be initialized with no image

   // cell.imageView.frame=CGRectMake(5,10,50,60);
    cell.imageView.layer.cornerRadius=8.0;
    cell.imageView.clipsToBounds=YES;
    cell.imageView.autoresizingMask=UIViewAutoresizingFlexibleHeight;
    [cell.imageView setImageWithURL:[NSURL URLWithString:[imaages objectAtIndex:indexPath.row]]placeholderImage:[UIImage imageNamed:@"Placeholder.png"]];
    cell.textLabel.text = [names objectAtIndex:indexPath.row];
    cell.backgroundColor=[UIColor clearColor];

    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

    return 80;

}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
}
解决方案 将图像剪裁到子视图,并向其中添加自动布局

[cell.contentView.superview setClipsToBounds:YES];
对于自定义单元格,请选择图像和


如果在加载完毕后重新加载tableview,则图像将获得预期的大小

[self.tableview reloadData];

这不是自定义单元格
imageView.autoresizingask
设置为
uiviewAutoResizinnone
Hmn,它曾经发生在我身上,但我在非ARC项目中,我正在viewController上释放viewController将消失。单击行时,您会做什么?尝试删除包含所有内容的if语句。请使用自定义UITableViewCell修复。您如何修复此问题?试试上面的链接,它解决了我的问题