ios - UITableView 单元格 Imageview 在单击时更改其大小?

标签 ios objective-c image uitableview

当我加载页面时它正常请检查下图

enter image description here

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

enter image description here

请帮我解决这个问题。这里我使用 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{
}

最佳答案

如果在加载完成后重新加载 tableview,图像将获得它应该具有的大小

[self.tableview reloadData];

关于ios - UITableView 单元格 Imageview 在单击时更改其大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23850072/

相关文章:

ios - 每次笔划更改用户文本字段输入并获取更改的消息

ios - 无法将类型 'UITableViewCell' 的值转换为 '(AppName).(CustomCellName)'

ios - UIButton 的 uiappearance 也会更改 UIBarButton 图像吗?

jquery - 从 JSON 编码的数据源中提取图像 URL

jquery - 单击图像检查输入 radio

ios - 苹果会拒绝只有登录的应用程序

ios - 将 canDisplayBannerAds 更改为 NO 不会更新 View 以删除广告横幅

ios - 通过 Pods 将 SocketRocket 添加到 Swift 项目

ios - UIDatePicker 输出

java - JFrame 未全屏显示所有图像