应用中用到tableView,在单元里面显示图片,但是现在显示出来的图片尺寸都被改变过,我希望能显示为原始图片的高和宽,不知道应该怎么弄?谢谢
想设置cell显示图片原始尺寸,用这段代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell=nil;
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
CGRect imageFrame = CGRectMake(2, 8, 40, 40);
UIImage *img = [[[UIImage alloc] initWithData:data] autorelease];
UIImageView *customImage = [[[UIImageView alloc] initWithFrame:imageFrame] autorelease];
customImage.image=img;
[cell.contentView addSubview:customImage];
}
return cell;
}
用[NSString stringWithFormat@"%@", strValue];
能获取自动释放的字符串,还能正常处理字符串strValue
所以:
NSMutableString *mstrValue = [NSMutableString stringWithFormat:@"%@", strValue];
或者
NSMutableString *mstrValue = [NSMutableString stringWithString:strValue];