Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.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 accessoryView按钮在实际设备上不可见_Ios_Uitableview_Uibutton - Fatal编程技术网

Ios 自定义UITableViewCell accessoryView按钮在实际设备上不可见

Ios 自定义UITableViewCell accessoryView按钮在实际设备上不可见,ios,uitableview,uibutton,Ios,Uitableview,Uibutton,在我的UITableView中,我想为表中的行添加customaccessoryview按钮;这是添加到UITableViewCellcellforrowatinexpath方法中的代码: UIImage *image = [UIImage imageNamed:@"icon.png"]; UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 28, 28)]; // tested also ini

在我的
UITableView
中,我想为表中的行添加
customaccessoryview
按钮;这是添加到
UITableViewCell
cellforrowatinexpath方法中的代码:

    UIImage *image = [UIImage imageNamed:@"icon.png"];
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 28, 28)]; // tested also initWithFrame:CGRectMake(0, 0, image.size.width, image.size.heigth)
    [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundImage:image forState:UIControlStateNormal];
    button.backgroundColor = [UIColor clearColor];

    cell.accessoryView = button;
    [button addTarget:self action:@selector(accessoryButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside];

这在iOS模拟器(iOS 5.1和iOS 6.1)上非常有效,我可以在表的每一行的右侧看到带有icon.png图像的自定义UIButton,还可以在自定义图像上调用accessoryButtonTapped事件。但如果我在真正的设备上测试我的应用程序(iPhone4和iOS 5.1或iPad3rd和iOS 6.1),我看不到自定义按钮,它是不可见的,事实上,点击每行的右侧仍会调用accessoryButtonTapped事件。我也删除并重新安装了应用程序,我能做什么?

如果调用了您的方法,则表示按钮在那里。问题在于你的形象。在设备上运行时,检查映像是否为零,以及映像是否已添加到构建目标。

哦,难以置信!我选择了唯一没有添加到构建目标的图像!出于某种奇怪的原因,“icon.png”不在应用程序文件夹中!非常感谢。