【问题标题】:How to resize the uitableview cell image?如何调整uitableview单元格图像的大小?
【发布时间】:2011-12-27 05:33:57
【问题描述】:

我需要在 uitableviewcell 中调整相同的图像大小。我使用相同的页面,而不是使用另一个视图。我把所有东西都放好就跑了。但我无法正确定位如何做到这一点。提前致谢。 这是代码

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
int count = 0;
if(self.editing && indexPath.row != 0)
    count = 1;

if(indexPath.row == ([imarry count]) && self.editing)
{
    cell.textLabel.text = @"ADD";
    cell.image= [UIImage imageNamed:@""];
    return cell;
}
cell.textLabel.text = [arry objectAtIndex:indexPath.row];
cell.image=[imarry objectAtIndex:(indexPath.row)];
return cell;    
 }


 - (void)imagePickerController:(UIImagePickerController *)UIPicker didFinishPickingImage:(UIImage *)info editingInfo:(NSDictionary *)dictionary
 {
[UIPicker dismissModalViewControllerAnimated:NO];
[imarry insertObject:info atIndex:[imarry count]];
[Table reloadData];
NSLog(@"Uploaded image");
}

图片图片是

【问题讨论】:

标签: iphone ios


【解决方案1】:

image 属性在 iOS 3.0 中已弃用。 您可以设置单元格的图像视图,但它是只读属性,因此您无法调整它的大小。

通过添加自定义图像视图,您可以解决您的目的。

【讨论】:

  • 如果我使用自定义图像视图,当我快速滚动时它会重叠。所以只有我不使用它。
  • 只需在“cellForRowAtIndexPath”中注释检查“if (cell == nil)”的代码行。
  • 所以它会创建新的单元格并且不会重叠。
  • 非常感谢。它工作正常。但是当我快速滚动时,自定义图像视图会减小宽度大小。但身高是正常的。如何解决这个问题
  • 为此您必须设置单元格的高度。为此使用此方法。 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
猜你喜欢
  • 2010-10-27
  • 1970-01-01
  • 1970-01-01
  • 2014-10-28
  • 1970-01-01
  • 2016-08-21
  • 2015-10-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多