相关疑难解决方法(0)

CGRectMake,CGPointMake,CGSizeMake,CGRectZero,CGPointZero在Swift中不可用

将代码转换为最新的swift 3.0后,我显示此错误.

在此输入图像描述在此输入图像描述

还告诉我解决方案 CGSize = CGSizeMake(0,0)

static var frameAtStartOfPan: CGRect = CGRectZero
static var startPointOfPan: CGPoint = CGPointZero
Run Code Online (Sandbox Code Playgroud)

哪个也不可用.

uikit swift3 ios10 xcode8

237
推荐指数
7
解决办法
16万
查看次数

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

我正在尝试使用以下代码在UITableViewCell中以宽度方式居中UIImageView:

        // 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];
Run Code Online (Sandbox Code Playgroud)

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

iphone uitableview uiimageview ipad ios

7
推荐指数
2
解决办法
1万
查看次数

标签 统计

ios ×1

ios10 ×1

ipad ×1

iphone ×1

swift3 ×1

uiimageview ×1

uikit ×1

uitableview ×1

xcode8 ×1