正在尝试将uibarbuttonstyleCamera添加到ios6中的uitableviewcell

正在尝试将uibarbuttonstyleCamera添加到ios6中的uitableviewcell,ios,objective-c,uitableview,uibutton,uibarbuttonitem,Ios,Objective C,Uitableview,Uibutton,Uibarbuttonitem,我正试图通过编程方式将uibarbutton-Camera样式添加到uitableviewcell中,如下所示 但是我在uitableviewcell中没有看到任何东西 UIButton *newBtn=[UIButton buttonWithType:UIBarButtonSystemItemCamera]; [newBtn setFrame:CGRectMake(250,10,50,30)]; [newBtn addTarget:self action:nil

我正试图通过编程方式将uibarbutton-Camera样式添加到uitableviewcell中,如下所示 但是我在uitableviewcell中没有看到任何东西

UIButton *newBtn=[UIButton buttonWithType:UIBarButtonSystemItemCamera];
        [newBtn setFrame:CGRectMake(250,10,50,30)];
        [newBtn addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
        [newBtn setEnabled:YES];
        [cell addSubview:newBtn];
  UIButton *newBtn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
        [newBtn setFrame:CGRectMake(250,10,50,30)];
        [newBtn addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
        [newBtn setEnabled:YES];
        [cell addSubview:newBtn];
但是当我使用这段代码时,我在uitableviewcell中看到一个圆形的rect按钮

UIButton *newBtn=[UIButton buttonWithType:UIBarButtonSystemItemCamera];
        [newBtn setFrame:CGRectMake(250,10,50,30)];
        [newBtn addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
        [newBtn setEnabled:YES];
        [cell addSubview:newBtn];
  UIButton *newBtn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
        [newBtn setFrame:CGRectMake(250,10,50,30)];
        [newBtn addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
        [newBtn setEnabled:YES];
        [cell addSubview:newBtn];

是否有任何方法可以添加uibarbuttonstyle按钮,或者我所能做的就是将uibutton圆角矩形样式添加到uitableviewcell?

UIBarButtonItem
uibutton
不同。它甚至不继承自
UIView
,因此不能将其作为子视图添加到其他视图中。你打电话时会发生什么

[UIButton buttonWithType:UIBarButtonSystemItemCamera]
是因为
uiBarButtonSystemCamera
常量对于类型为:的
按钮无效,因此UIButton无法决定返回哪种类型的按钮-可能只是返回一个未配置的空按钮或
nil

所以你的问题没有简单的解决办法。您可以做的是,例如,拍摄摄像头栏按钮项目的屏幕截图,然后使用某种图像编辑器应用程序提取其图像,然后将该图像设置为自定义
ui按钮的图像,如下所示:

UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setImage:[UIImage imageNamed:@"Camera.png"] forState:UIControlStateNormal];
[cell.contentView addSubview:btn];