我有一個包含三個容器移動一個UIView上的UITableView的頂部 - 接觸頂部的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的幀(我示出了一個UIView查看(標記爲O)B的右側,這並不重要)。現在容器B是重疊的容器
O - Other view (unimportant)
$ - original location of touch @
----------------------
| | | |
| --|* B | |
| --| | |
| -A|------------ |O|
| --||@-$--C----| | |
| |------------ | |
----------------------
但是現在,當我試圖通過觸摸行(@)的左邊緣,選擇在容器C的UITableView的一排,觸摸是由容器的UITableView的註冊。或者即使我觸摸表格(*)上方的視圖,也會選擇A中相應的行。
我可以通過更改容器A的UITableView的寬度來解決部分問題。但是,如果我觸摸表C(@),那麼我仍然有問題,C的行不會選擇。這就像表C的起始位置在舊位置($)中一樣。
那麼,我可以做什麼,以便在新的@位置點擊會在C中選擇正確的行?
=======
編輯一些代碼:
這是我的代碼做容器B.這是B的框架的一個非常簡單的動畫。 self.view是容器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
@Beppe,我爲動畫添加了代碼。 – David