【发布时间】:2010-10-16 14:58:53
【问题描述】:
我正在使用图像来显示 UITableViewCell 的全部内容,它是使用 backgroundView 属性设置的。
我的问题是它总是被缩放以适应单元格。有没有办法在这种情况下禁用缩放,所以我只能提供 480 像素的版本,当方向是纵向时它只会被裁剪?
我是这样做的:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
UIImageView *bgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"menu.0%d.large.png", indexPath.row+1]]];
UIImageView *selectedBgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"menu.0%d.large.selected.png", indexPath.row+1]]];
cell.backgroundView = bgView;
cell.selectedBackgroundView = selectedBgView;
[bgView release];
[selectedBgView release];
return cell;
}
当方向改变时,我尝试使用两个版本的图像在它们之间切换。到目前为止,这也是可行的,但它的缺点是在处理动画时总是会看到缩放。
感谢您的帮助
阿恩
【问题讨论】:
标签: objective-c uitableview ios4 uiimageview