Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何在tableViewCell中舍入UIImageView的角_Iphone_Ios_Cocoa Touch_Ios5 - Fatal编程技术网

Iphone 如何在tableViewCell中舍入UIImageView的角

Iphone 如何在tableViewCell中舍入UIImageView的角,iphone,ios,cocoa-touch,ios5,Iphone,Ios,Cocoa Touch,Ios5,我试图让uiimagview在tableviewcell中具有圆角,代码如下: #import <QuartzCore/QuartzCore.h> (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { HomepwnerItemCell *cell = (HomepwnerItemCell *)[tableView d

我试图让uiimagview在tableviewcell中具有圆角,代码如下:

#import <QuartzCore/QuartzCore.h>    
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    HomepwnerItemCell *cell = (HomepwnerItemCell *)[tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];    

    Possession *possession = [self.possessions objectAtIndex:indexPath.row];
    cell.valueLabel.text = [@"$" stringByAppendingString:[[NSNumber numberWithInt:possession.valueInDollars] stringValue]];
    cell.nameLabel.text = possession.possessionName;

    UIImage *image = [[ImageCache sharedImageCache] imageForKey:possession.imageKey];      
    UIImageView *roundedImage = [[UIImageView alloc] initWithImage:image];
    roundedImage.layer.masksToBounds = YES;
    roundedImage.layer.cornerRadius = 10.0;
    cell.imageView = roundedImage;
    // cell.imageView.image = [[ImageCache sharedImageCache] imageForKey:possession.imageKey];
    return cell;
}
#导入
(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
HomepwnerItemCell*单元格=(HomepwnerItemCell*)[tableView dequeueReusableCellWithIdentifier:@“UITableViewCell]”;
占有*占有=[self.Occessions objectAtIndex:indexPath.row];
cell.valueLabel.text=[@“$”字符串通过附加字符串:[[NSNumber numberWithInt:Occession.valueInDollars]stringValue]];
cell.namelab.text=Occession.OccessionName;
UIImage*image=[[ImageCache sharedImageCache]imageForKey:Occession.imageKey];
UIImageView*RoundeImage=[[UIImageView alloc]initWithImage:image];
roundedImage.layer.masksToBounds=是;
RoundeImage.layer.cornerRadius=10.0;
cell.imageView=roundedImage;
//cell.imageView.image=[[ImageCache sharedImageCache]imageForKey:Occession.imageKey];
返回单元;
}
但是当我运行它时,图像在tableViewCells中显示为空白

如果我只做
cell.imageView.image=[[ImageCache-sharedImageCache]imageForKey:converage.imageKey],它就可以正常工作(但不带圆角)


我做错了什么?

您需要使用quartz框架。下面是转弯和向图像添加边框的代码

cell.imageView.layer.cornerRadius = 10.0;
cell.imageView.layer.borderColor = [UIColor blackColor].CGColor;

cell.imageView.layer.borderWidth = 1.2;
cell.imageView.clipsToBounds = YES;
首先将图像设置为imageview,然后更改imageview图层的使用

cell.imageView.layer.cornerRadius=20;  //Use as ur specified corner length
也实施

  <QuartzCore/QuartzCore.h>


cell.imageView=[roundedImage Image];请尝试此操作。错误:自动引用计数问题:例如,接收器类型“UIImageView”消息未使用选择器“Image”声明方法检查UIImage*图像是否已分配内存?除非您没有完整粘贴上述方法,在担心圆角之前,您需要先修复tableView:cellForRowAtIndexPath:code。如果没有可重复使用的单元格,您就不会在其中分配新的单元格??在ios5中新增:“如果没有可回收的现有单元格,dequeueReuseableCell将自动创建原型单元格的新副本并将其返回给您。”但我有
#import
您是否能够在没有“角落”代码的情况下看到图像。您正在设置的图像的尺寸是多少啊这很有效,显然我只需要先设置图像,然后再更改imageview layer.cell.imageview.layer.cornerRadius=[cell.imageview.image size].height/2//给你一个圆形的图像。