【发布时间】:2014-07-14 01:02:55
【问题描述】:
当我加载页面时,请检查下面的图片
当我点击一行时,相应的图片会以不同的尺寸显示,请检查下图(当我点击第一行和第二行时)
请帮我解决这个问题。这里使用 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{
}
【问题讨论】:
-
使用自定义 uitableviewcell 修复
-
你是如何解决这个问题的?
-
UItableViewCell imageview changing on select 试试上面的链接它解决了我的问题
标签: ios objective-c image uitableview