- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我的单元格是这样设置的:
- (UITableViewCell *)tableView:(UITableView *)tableViewIn cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"subcategory";
UITableViewCell *cell = [tableViewIn dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = [[subcategories objectAtIndex:indexPath.row] title];
cell.textLabel.font = [UIFont boldSystemFontOfSize:16];
cell.textLabel.font = [UIFont boldSystemFontOfSize:16];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.selectionStyle = UITableViewCellSelectionStyleGray;
cell.contentView.backgroundColor = [UIColor clearColor];
cell.textLabel.textColor = [UIColor whiteColor];
cell.textLabel.highlightedTextColor = [UIColor whiteColor];
return cell;
}
如您所见,我设置了 contentView
的背景,效果很好 - 但是当我尝试对 backgroundView
或 做同样的事情时>accessoryView
,没有任何反应,因为backgroundView
和accessoryView
似乎都是nil。
当设置accessoryType
而不是accessoryView
时,如何设置配件的背景?
最佳答案
来自 UITableViewCell Class Reference :
背景 View
Discussion
The default is nil for cells in plain-style tables (UITableViewStylePlain) and non-nil for grouped-style tables UITableViewStyleGrouped). UITableViewCell adds the background view as a subview behind all other views and uses its current frame location.
附件 View
Discussion
If the value of this property is not nil, the UITableViewCell class uses the given view for the accessory view in the table view’s normal (default) state; it ignores the value of the accessoryType property. The provided accessory view can be a framework-provided control or label or a custom view. The accessory view appears in the the right side of the cell.
在您定义它们之前,这些 View 将为零,因此您可以根据需要设置它们的背景。
关于iphone - UITableViewCell accessoryType 已设置,但 accessoryView 为 nil。如何设置 accessoryView backgroundColor?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3714676/
我的单元格是这样设置的: - (UITableViewCell *)tableView:(UITableView *)tableViewIn cellForRowAtIndexPath:(NSInde
我有一个分组的表格 View ,首先我想删除顶部和底部分隔符。我环顾四周,找到了一个对我来说非常有效的解决方案。这是通过将 UIView 添加到单元格的底部来充当分隔符。现在看起来棒极了。但我面临的问
我有一个 TableView ,其中一行在两个附件 View 之间切换。问题是当我让它显示非默认附件 View 时,我无法让它切换回来。 这是我正在尝试的方法。如果 actionAlertBadge
当我将 UITableViewCells backgroundColor 设置为半透明颜色时,它看起来不错,但颜色没有覆盖整个单元格。 imageView 和 accessoryView 周围的区域将
我有一个 tableview,我想自定义 accessoryview 按钮。为此,我有带有半透明像素的自定义 PNG 图像。 UIButton *myAccessoryButton = [[UIBut
我想在 UITableViewCell 中显示一个动画圆。我已经获得了以下代码,可用于 self.view,但是当我尝试将其添加到 cell.accessoryview 时,它永远不会绘制。有人知道为
我需要将 accessoryView 更改为正确的 UIImageView func tableView(tableView: UITableView, cellForRowAtIndexPath i
我有一个复选框,当它被选中时,它会被选中。但是当我选择单元格时,突出显示会覆盖复选框。对不起,我的英语很糟糕,但这是下面的代码。有没有办法让我在突出显示的顶部添加复选标记按钮? -(UITableVi
我完全不确定为什么我的辅助 View 不起作用。我只是想让一些文本显示在 UITableViewCell 的右侧(以及左侧),但只显示左侧的文本。 - (UITableViewCell *)table
我在 accessoryView 中有一个带有 UISwitch 的 UITableviewCell,它在运行时正确显示,但是一旦我旋转设备,开关就不再位于正确的位置。 我可以使用约束而不使用 acc
我有一个 TableView ,我想在每个单元格的右侧放置一个标签,所以在 - (UITableViewCell *)tableView:(UITableView *)tableView cellFo
我试图在选择行时更改 UITableViewCell 的附属 View ,我有以下代码: - (void)tableView:(UITableView *)aTableView didSelectRo
我尝试将 AccessoryView 添加到 NSSavePanel,但有时 AccessoryView(它的元素)会被禁用,有时则不会。希望大家有想法。 这是我的代码: NSWindow *
我有一个 TableView,我想在它被点击时为一行添加复选标记。为此,我有: - (void)tableView:(UITableView *)tableView didSelectRowAtInd
我正在尝试在尺寸相同的 24x24 单元格中显示多个图像。我把它们放在这样的循环中: cell!.accessoryView = UIView() for url in arrURL { ce
在我的 UITableView 中,我想为表格中的行添加 custom accessoryView 按钮;这是在 UITableViewCell cellForRowAtIndexPath 方法中添加
在我的 iOS 应用程序中,我创建了一个 UIAlert 并向其动态添加了一个 UITextView: UIAlertView *tweetAlert = [[UIAlertView alloc]
我正在尝试构建一个 UITableView,每个单元格中都有一些长文本。单元格没有 AccessoryView,除了一个单元格(第 8 个),这是一种打开详细 View 的按钮。 考虑这段代码: -
我正在尝试为 UITableView 使用自定义 accessoryView。作为 accessorView,我正在使用 UIImageView。我面临的问题是 accessoryView 只出现在
我在屏幕键盘 (accessoryView) 上方显示了一个带有附加键的栏。我目前正在使用 replaceCharactersInRange:withString: 将按下的字符插入到 UITextF
我是一名优秀的程序员,十分优秀!