在旋转的 UITableView 内旋转 UITableViewCell
我没有实现一个笨重的、可能存在错误的自定义表,而是使用了更简单的旋转表选项。当我决定不初始化旋转内容,而是旋转单元格本身并减少复杂单元格中的代码量时,问题就出现了。
以下几行紧接在单元配置之后。
这会导致每个单元在负载时旋转 90°,无论方向如何:
cell.transform =
(CGAffineTransform)CGAffineTransformRotate(cell.transform, (M_PI / 2.0));
cellRotated = YES;
并且此选项仅将第一个单元旋转一次,但保留旋转:
if (!cellRotated) {
cell.transform =
(CGAffineTransform)CGAffineTransformRotate(cell.transform, (M_PI / 2.0));
cellRotated = YES;
}
可以使用现有函数(或其集)跟踪单元方向吗?
我用谷歌找不到任何关于这个的信息。有相关的问题,但主要是关于表格和纵向/横向 UI 方向,因此反向旋转的实现有很大不同。
编辑
如果我将cellRotated = YES
移动到viewDidAppear:
,除了一个单元格之外的每个单元格都会旋转。 (然后单元格重用使得在这种情况下,每六个单元格都保持不变。)
1-5 是好的,6 是坏的,7-11 是好的,12 是坏的,等等(然后当我到达表格的末尾时,它会以完全合乎逻辑但完全不想要的模式发生变化)
中途或后退一步,我不知道,但这就是我现在所拥有的。
Rather than implementing a clunky, potentially bug-ridden custom table, I went with the much simpler rotate table option. The problem comes in when I decide that, rather than initializing rotated contents, I want to rotate the cell itself and cut down on the amount of code in complex cells.
The following lines are immediately after cell configuration.
This causes every cell to rotate 90° on load, regardless of orientation:
cell.transform =
(CGAffineTransform)CGAffineTransformRotate(cell.transform, (M_PI / 2.0));
cellRotated = YES;
And this option only rotates the first cell once, but preserves the rotation:
if (!cellRotated) {
cell.transform =
(CGAffineTransform)CGAffineTransformRotate(cell.transform, (M_PI / 2.0));
cellRotated = YES;
}
Can cell orientation be tracked with an existing function (or set thereof)?
I can't find anything about this with Google. There are related questions, but mostly about tables and Portrait/Landscape UI orientations, so the counter-rotation implementation is quite a bit different.
EDIT
If I move cellRotated = YES
to viewDidAppear:
every cell except one gets rotated. (And then cell reuse makes it so that, in this case, every sixth cell is left alone.)
1-5 is good, 6 is bad, 7-11 is good, 12 is bad, etc (and then it changes in a perfectly logical but entirely unwanted pattern when I hit the end of the table)
Halfway there or a step back, I don't know, but that's what I have now.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果旋转是您所做的唯一变换那么为什么不这样做,
然后,
If rotation is the only transform you do then why don't you just do this,
and then,