当我加载页面时它正常请检查下图
当我点击一行时,相应的图像以不同的尺寸显示,请检查下图(当我点击第一行和第二行时)
请帮我解决这个问题。这里我使用 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/