【发布时间】:2012-01-11 20:38:47
【问题描述】:
我想自定义一个 UITableViewCell 的附属视图,所以我需要一个 UIImage。 我希望该图像类似于“添加联系人”类型的按钮(那个蓝色加号)。
我该怎么做?
【问题讨论】:
标签: iphone uitableview ios5 uiimageview uiimage
我想自定义一个 UITableViewCell 的附属视图,所以我需要一个 UIImage。 我希望该图像类似于“添加联系人”类型的按钮(那个蓝色加号)。
我该怎么做?
【问题讨论】:
标签: iphone uitableview ios5 uiimageview uiimage
您可以通过使用UIButtonTypeContactAdd 类型创建UIButton 并将其添加为单元格的accessoryView 来实现。
UIButton contactAddButton = [UIButton buttonWithType:UIButtonTypeContactAdd];
cell.accessoryView = contactAddButton;
【讨论】:
解决了。如果我将用户交互设置为禁用,它只是没有点击交互并且表现得像图像。
UIButton *contactAddButton = [UIButton buttonWithType:UIButtonTypeContactAdd];
[contactAddButton setUserInteractionEnabled:FALSE];
cell.accessoryView = contactAddButton;
【讨论】:
userInteractionEnabled 设置为NO 的按钮不会执行任何操作,因为它是系统中无处不在 的按钮,您的用户会对它为什么不执行任何操作感到困惑。
【讨论】: