首页 \ 问答 \ 为什么所有的背景消失在UITableViewCell选择?(Why do all backgrounds disappear on UITableViewCell select?)

为什么所有的背景消失在UITableViewCell选择?(Why do all backgrounds disappear on UITableViewCell select?)

我当前的项目的UITableViewCell行为令我感到困惑。 我有一个非常简单的UITableViewCell子类。 它为基础视图添加了一些额外的元素(通过[self.contentView addSubview:...]并在元素上设置背景颜色,使其看起来像黑色和灰色矩形框。

因为整个表的背景具有这样一个具体的纹理图像,每个单元格的背景都需要是透明的,即使被选中,但在这种情况下它应该变暗一点。 我设置了一个自定义半透明选择的背景来实现这一效果:

UIView *background = [[[UIView alloc] initWithFrame:self.bounds] autorelease];
background.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];
background.opaque = NO;

[self setSelectedBackgroundView:background];

虽然这样可以看出背景,但是当我选择单元格时,会发生奇怪的副作用; 所有其他背景都是以某种方式摆脱的 。 这是一个截图。 底部细胞看起来应该和没有被选中。 选择顶部单元格,但应显示黑色和灰色矩形区域,但它们已经消失!

模拟器的屏幕快照。选中顶部单元格,底部不是。

谁知道这里发生了什么,甚至更重要:我该如何纠正?


My current project's UITableViewCell behavior is baffling me. I have a fairly straightforward subclass of UITableViewCell. It adds a few extra elements to the base view (via [self.contentView addSubview:...] and sets background colors on the elements to have them look like black and grey rectangular boxes.

Because the background of the entire table has this concrete-like texture image, each cell's background needs to be transparent, even when selected, but in that case it should darken a bit. I've set a custom semi-transparent selected background to achieve this effect:

UIView *background = [[[UIView alloc] initWithFrame:self.bounds] autorelease];
background.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];
background.opaque = NO;

[self setSelectedBackgroundView:background];

And although that yields the right look for the background, a weird side effect happens when I select the cell; all other backgrounds are somehow turnt off. Here's a screenshot. The bottom cell looks like it should and is not selected. The top cell is selected, but it should display the black and grey rectangular areas, yet they are gone!

Screenshot of the simulator. The top cell is selected, the bottom is not.

Who knows what's going on here and even more important: how can I correct this?


原文:https://stackoverflow.com/questions/7053340
更新时间:2021-12-26 09:12

最满意答案

我使用D3D11_QUERY_PIPELINE_STATISTICS类型的ID3D11Query解决了它。 结构D3D11_QUERY_DATA_PIPELINE_STATISTICS用于结果,它有很多有用的信息,如渲染基元的数量和着色器的调用等。


I solved it using an ID3D11Query of the type D3D11_QUERY_PIPELINE_STATISTICS. The struct D3D11_QUERY_DATA_PIPELINE_STATISTICS is used for the result, and it has a lot of useful information like number of rendered primitives and invocations of the shaders etc.

相关问答

更多
  • 我在代码中发现了问题 for row = 1:N1 for col = 1:N2 pixNum = N1*N2 + (row-1)*N2 + col; pixelVals(pixNum,1) = image1_gray(row,col); registeredPts(pixNum,:) = [r1(col,:),r2(col,:)]; end end 这里相同的注册点一次又一次地重新分配,我通过使用re ...
  • 我使用D3D11_QUERY_PIPELINE_STATISTICS类型的ID3D11Query解决了它。 结构D3D11_QUERY_DATA_PIPELINE_STATISTICS用于结果,它有很多有用的信息,如渲染基元的数量和着色器的调用等。 I solved it using an ID3D11Query of the type D3D11_QUERY_PIPELINE_STATISTICS. The struct D3D11_QUERY_DATA_PIPELINE_STATISTICS is us ...
  • 设三角形为3点p1 =(x_1,y_1) , p2 =(x_2,y_2) , p3 =(x_3,y_3) 。 设p1,p2,p3为位置向量。如果原点位于其中,那么任何一个位置向量与其他两个的交叉乘积将在符号上不同(一个负数,一个正数)。 但如果原点位于外面,则会有一个点与其他点都有负交叉积。 因此,对于每个点,我找到十字积小于0的点。现在,如果你选择这两个点中的任何两个并且与点i一起形成一个三角形,则原点将在此三角形之外。这就是为什么你从res中减去(选择2)从这些点+点i)。 这是迄今为止许多实施的最佳解 ...
  • 你描述的方法非常接近,但不会计算网格中所有的全等三角形。 最重要的省略是由于存在旋转来保存整数坐标,但不是90度的倍数。 考虑具有顶点(0,0),(240,0)和(240,180)的三角形。 通过arcsin(3/5)或大约37度逆时针绕原点旋转,以获得顶点(0,0),(192,144)和(84,288)的全等三角形。 新三角形的边框比原有的长宽比不同,这也引入了一些困难。 这是一个算法,给定NxN网格上的三个点,应该枚举O(N 3 )时间内的所有全等三角形。 设P =(x,y)表示具有整数坐标的点 T(p ...
  • 暗示 我假设所有三角形都是这样的形式: --- - 而不是像: - or - or - --- -- -- - - 注意2个单位的三角形由三个1单位三角形组成。 3个单位的三角形由3个重叠的2个单位三角形组成,依此类推。 下图是由三个2单位三角形组成的3单位三角形的示例,这些三角形本身由三个单位三角形组成 - -+ -+* +* * --- +++ *** - + * ...
  • 补丁只是一个没有真正内在结构的点的集合......你的TCS和TES是有意义的。 与GL_TRIANGLES (由3个顶点严格定义)不同, GL_PATCHES每个补丁没有预定义的顶点数。 您可以使用以下方法自行设置补丁中的顶点数: glPatchParameteri ​(GL_PATCH_VERTICES​​, N); // where N is some value less than GL_MAX_PATCH_VERTICES 然后,绘制的每个N many顶点定义一个新的补丁基元。 补丁实际上只是用 ...
  • 如果你可以在常数时间内执行searchNeighbor(edge)和centers.get(),或者如果searchNeighbor(edge)需要O(log N)时间,则该算法为O(N)。 通过制作地图可以很容易地满足其中任何一个:edge - >(三角形,三角形),searchNeighbor()会参考。 如果您使用哈希映射,您将获得预期的O(N)时间。 在N个点的Delaunay三角剖分中有O(N)个三角形,所以: 建筑中心增加O(N)中心并花费O(N)时间 有O(N)三角形,点对 每个三角形有3条边 ...
  • 假设您的三角形是A:A1A2A3和B:B1B2B3 1)计算N1,A1A2和A1A3的归一化叉积。 2)测试B由A“看”,即N1•A1B1> 0。 3)计算N2,B1B2和B1B3的归一化交叉积。 如果你想测试'严格面对',那么测试N1•N2 == -1(其中•是点积)。 对于不太严格的面对,你可以测试N1•N2 - ( - 1)<一些小值。 正如@BenAaronson指出的那样,你可能想通过测试(A1A2,A1A3)和(B1B2,B1B3)来共同测试rectn是否在同一平面上。 如果O是原点,则测试N1 ...
  • 可以使用简单的递归找到单个三角形(内部和外部细分相等)的重心细分的三角形数量: // Calculate number of triangles produced by barycentric subdivision (i.e. tessellation) // Where n is the level of detail lod and outer and inner level is always equal int calculateTriangles(int n) { if(n < 0) ...
  • calculateTriangles函数给出的序列是算术级数之和 ,因此calculateTriangles(n)值约为3/2 * n^2 似乎你需要某种反向函数A*Sqrt(x) calculateTriangles function gives sequence that is sum of arithmetic progression, so calculateTriangles(n)value is about 3/2 * n^2 Seems you need some kind of revers ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。