Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.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
Ios 将按钮添加到uitableviewcell,但未显示_Ios - Fatal编程技术网

Ios 将按钮添加到uitableviewcell,但未显示

Ios 将按钮添加到uitableviewcell,但未显示,ios,Ios,我正在将删除按钮添加到cellforrowatinexpath: 但是按钮没有出现 double deleteYOffset=10; double deleteW=100; double deleteH=100; UIButton *deleteButton =[UIButton buttonWithType:UIButtonTypeCustom]; deleteButton.frame=CGRectMake(imageXoffset, deleteYOffset, deleteW, dele

我正在将删除按钮添加到
cellforrowatinexpath:
但是按钮没有出现

double deleteYOffset=10;
double deleteW=100;
double deleteH=100;

UIButton *deleteButton =[UIButton buttonWithType:UIButtonTypeCustom];
deleteButton.frame=CGRectMake(imageXoffset, deleteYOffset, deleteW, deleteH);
UIImage *image = [UIImage imageNamed:@"Delete.png"];
[deleteButton setBackgroundColor:[UIColor greenColor]];
[deleteButton setImage:image forState:UIControlStateNormal];
[[cell contentView ]addSubview:deleteButton];

没有足够的代表,因此无法发表评论,但您似乎缺少imageXoffset

我使用以下命令复制了您的代码:

double imageXoffset = 10;
并且能够看到我的细胞的按钮渲染。基于此,我猜测偏移设置不正确,并渲染视图中的按钮


还将移动视图代码考虑到 CuoCyto类中,并将 CuoCyto实例化为 CyfFurWaldRexPosith。您应该能够通过xCode UI绑定图像,而不必定义偏移量/高度和宽度。

Delete.PNG是IOS的保留字……我将图像更改为delete1,它成功了。

您是否尝试过:[cell addSubview:deleteButton];是的。还要确认图像是否存在。我最好使用InitWithFrame,而不是分配它,然后设置帧imageXoffset在哪里?好的。我想出来了。细胞没有被创造出来…啊。这就解释了。我试用了包含“Default.png”的代码,一切正常。