iphone – 无论方向如何,如何将UIImageView置于UITableViewCell中心?

iphone – 无论方向如何,如何将UIImageView置于UITableViewCell中心?,第1张

概述我正在尝试使用以下代码在UITableViewCell中以宽度方式中心UI ImageView: // self.cover_image is a UIImage variable // cell is a UITableCellView UIImageView* backcover_imageview = [[[UIImageView alloc] initWi 我正在尝试使用以下代码在UItableVIEwCell中以宽度方式中心UI ImageVIEw:

// self.cover_image is a UIImage variable        // cell is a UItableCellVIEw        UIImageVIEw* backcover_imagevIEw = [[[UIImageVIEw alloc] initWithImage:self.cover_image] autorelease];        [backcover_imagevIEw sizetoFit];        //center image        //float xPos = cell.contentVIEw.frame.size.wIDth - (self.cover_image.size.wIDth/2);        //Todo: need better solution        //Eyeballing attempt:        float xPos = self.cover_image.size.wIDth - 25;        CGRect bookcover_frame = backcover_imagevIEw.frame;        bookcover_frame.origin.x = xPos;        backcover_imagevIEw.frame = bookcover_frame;        backcover_imagevIEw.tag = 9000;        backcover_imagevIEw.autoresizingMask = UIVIEwautoresizingFlexibleleftmargin | UIVIEwautoresizingFlexibleRightmargin;        [cell.contentVIEw addSubvIEw:backcover_imagevIEw];

我试图将UIImageVIEw置于UItableCellVIEw中心,无论iPad或iPhone设备的方向如何.有谁知道正确的方法吗?

解决方法 将backcover_imageVIEw添加到单元格的contentVIEw后,使用它来居中它:

imageVIEw.center = CGPointMake(cell.contentVIEw.bounds.size.wIDth/2,cell.contentVIEw.bounds.size.height/2);
@H_403_27@ 总结

以上是内存溢出为你收集整理的iphone – 无论方向如何,如何将UIImageView置于UITableViewCell中心?全部内容,希望文章能够帮你解决iphone – 无论方向如何,如何将UIImageView置于UITableViewCell中心?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1084265.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存