自定义UITableViewCell中的UIButton在旋转后停止工作

时间:2013-01-17 20:51:22

标签: ios ipad uitableview rotation orientation

问题:

我使用了包含两个按钮的自定义UITalbeViewCell,它们在纵向方向上工作正常。旋转后,它们都停止响应按钮内部功能。有些人的问题是他们的按钮在旋转后无法正确绘制。我看起来很好,因为按钮在旋转后显示在正确的位置,但它们不再响应按钮按下了。

对于我的应用程序中的这个特定视图,我使用UIPageController在视图中实现多个页面,对于嵌入在页面滚动控制器中的视图(现在将其命名为EmbeddedView),有一个包含自定义UITableViewCell的UITableView。自定义表格视图单元格只有一个笔尖,文件的所有者是EmbeddedView。

在EmbeddedView中

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
/*===== This is the most memory efficient way of creating table view cells =====*/

static NSString *CellIdentifier = @"CellIdentifier";

CustomTableViewCell *cell = (CustomTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
    [[self customTableCellNib] instantiateWithOwner:self options:nil];
    cell = [self customTableCell];
    [self setCustomTableCell:nil];
    }
}

我尝试了什么:

我为自定义表格视图单元格创建了另一个nib文件并在-cellForRowAtIndexPath()中使用它,我检查了方向并使用不同的笔尖动态创建单元格,没有运气。

我在-didRotateFromInterfaceOrientation()中添加了[tableview reloadData],没有做任何事情。

有人会指出我正确的方向吗?任何帮助表示赞赏。

这是IB中的自动调整表格视图:

enter image description here

看起来不对,但按钮无效

enter image description here

更新:我尝试在IB中为表格视图指定不同的自动调整大小掩码,结果如下所示:

&LT 1为卤素;

enter image description here enter image description here

enter image description here

&LT 2 - ;

enter image description here enter image description here

enter image description here

&LT 3的密度;

enter image description here

enter image description here

&LT 4是氢;

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:4)

您是否检查了如何调整超级视图的大小?

检查超级视图是否已选中“剪辑到边界”。如果不检查它。这将使视图剪辑其内容,以便您查看它是否正在调整大小。

我认为超级视图没有正确调整大小,因此触摸事件也没有很好地传递。

编辑 - 所以这是可以让OP达成解决方案的提示:

  

我通常会在调整大小时出现意外行为等情况,例如将层次结构中的每个视图更改为不同的,可识别的颜色。现在你有了视图A和视图B具有相同的背景颜色(或清晰),你不会看到视图B是否正在调整大小。祝你好运。