开发者

How to get the height and width of the image placed in a custom cell in ios

I have a custom cell,and it has a image in it..and I am accessing that image in this way in

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
 [[tableCell specialImage] setImage:[UIImage imageNamed:@"One.png"]];
}

So now I want to know how can i get the hieght and width of this 开发者_开发百科"special image"..

Waiting for your reply


I think you are searching for that size:

CGRect size = [tableCell specialImage].bounds.size;


As per comments, I'd expect the following to work:

 CGSize specialImageSize = [[tableCell specialImage] size];

If that doesn't work, you'll need to post more code for more help. For example, if the above doesn't work, it'd be helpful to know more about what I assume is a UITableViewCell subclass pointed to by tableCell.


Please try below code:

UIImage *imageThatIsSpecial = [UIImage imageNamed:@"One.png"];

NSLog(@"Image height is %f and its width is %f",imageThatIsSpecial.size.height, imageThatIsSpecial.size.width);

[[tableCell specialImage] setImage:imageThatIsSpecial];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜