【发布时间】:2013-08-08 01:06:09
【问题描述】:
我有一个包含三个容器的 UIView
Container A - contains a UITableView
Container B - contains Container C and Container O
Container C - contains a UITableView
* - touch event
@ - touch event
----------------------
| | |
| ---*| B |
| --- | |
| -A- | ----------- |
| --- ||@----C---- | |
| | ----------- |
----------------------
在我移动容器 B 的框架时发生了一个事件(并且我在 B 的右侧显示了一个视图(标记为 O),这并不重要)。现在容器 B 与容器 A 重叠
O - Other view (unimportant)
$ - original location of touch @
----------------------
| | | |
| --|* B | |
| --| | |
| -A|------------ |O|
| --||@-$--C----| | |
| |------------ | |
----------------------
但是现在,当我尝试通过触摸行的左边缘 (@) 来选择容器 C 的 UITableView 中的一行时,容器 A 的 UITableView 正在注册触摸。或者即使我触摸表格上方的视图 (*),也会选择 A 中的相应行。
我可以通过改变Container A的UITableView的宽度来解决部分问题。但是我仍然有一个问题,如果我触摸表 C (@),C 的行不会选择。就像表 C 的开头位于旧位置 ($) 一样。
那么我该怎么做才能在新的@位置点击将在 C 中选择正确的行?
=======
编辑一些代码:
这是我在容器 B 中编写的代码。它是 B 帧的非常直接的动画。 self.view 是 Container B 的 UIView。
所有视图都通过情节提要显示在屏幕上(“其他”容器被隐藏)。其他容器是 B 的子视图。
// this code basically aligns the "other" container to the right/"offscreen" of
// Container B. Yes extending beyond the frame of B, but this part works fine
CGRect otherContainerFrame = self.otherContainerView.frame;
otherContainerFrame.origin.x = CGRectGetMaxX(self.view.frame);
[self.otherContainerView setFrame:otherContainerFrame];
[self.otherContainerView setHidden:NO];
// I'm going move Container B by the width of the "other" view
float offset = CGRectGetWidth(self.otherContainerView.frame);
CGRect frame = self.view.frame;
frame.origin.x -= offset;
[UIView animateWithDuration:.35
animations:^{
[self.view setFrame:frame];
}
];
请让我知道您还想看什么其他代码。
【问题讨论】:
-
很好的解释,但我认为我们需要查看用于显示和动画容器的代码来解决这个问题...
-
@Beppe,我为动画添加了代码。
标签: ios objective-c cocoa-touch uitableview uiview