UIView叠加层对触摸没有反应

时间:2014-05-02 17:49:00

标签: ios objective-c uiview

我在我们的应用程序中显示UIView叠加层,方法是将视图包含在父视图中的两个兄弟之一中,并将frame.y坐标放在屏幕底部。然后,我将这个框架的移动设置为兄弟姐妹的动画。 hiddenYOrigin值是一个浮点数,用于保存原始的屏幕外y值:

- (void)awakeFromNib
{
    hiddenYOrigin = self.frame.origin.y;
}

然后我从另一个视图调用showAnimated:

- (void)showAnimated
{
    CGRect frame = self.superview.frame;
    frame.origin.y = -hiddenYOrigin + 20;

    [UIView animateWithDuration:0.4 animations:^{
        self.superview.frame = frame;
    } completion:^(BOOL finished){
        [self.controller overlayDidShow:self];
    }];
}

这确实显示了叠加层,并且是我们在其他应用中使用的完全相同的机制,但无论出于何种原因,此应用中叠加层对触摸完全没有响应。它有几个按钮用于各种操作,包括隐藏覆盖图,但没有接收任何触摸。

我添加了一个hitTest函数来调试是否有任何触摸通过,但没有任何触摸触发hitTest。

有什么想法吗?

编辑:

这是运行" po"的输出。 @robmayoff提到的命令:

(lldb) po [[UIApp keyWindow] recursiveDescription]
<UIWindow: 0xbb47ab0; frame = (0 0; 320 480); gestureRecognizers = <NSArray: 0xbb47f70>; layer = <UIWindowLayer: 0xbb47b90>>
   | <UILayoutContainerView: 0xbae7780; frame = (0 0; 320 480); autoresize = W+H; gestureRecognizers = <NSArray: 0xbab2370>; layer = <CALayer: 0xba5be40>>
   |    | <UINavigationTransitionView: 0xbafb770; frame = (0 0; 320 480); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0xbaf6090>>
   |    |    | <UIViewControllerWrapperView: 0xbb783d0; frame = (0 0; 320 480); autoresize = RM+BM; layer = <CALayer: 0xbb78480>>
   |    |    |    | <UIView: 0x10b6efc0; frame = (0 0; 320 480); clipsToBounds = YES; autoresize = RM+BM; layer = <CALayer: 0x10b6f020>>
   |    |    |    |    | <UIView: 0x10b6d920; frame = (54 20; 266 460); autoresize = LM+BM; layer = <CALayer: 0x10b6d980>>
   |    |    |    |    |    | <UITableView: 0xc215e00; frame = (0 44; 266 400); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x10b6ced0>; layer = <CALayer: 0x10b6ca70>; contentOffset: {0, -20}>
   |    |    |    |    |    |    | <UITableViewWrapperView: 0x10b6d1d0; frame = (0 0; 266 400); autoresize = W+H; layer = <CALayer: 0x10b6d240>>
   |    |    |    |    |    |    |    | <CustomButtonCell: 0x10ba6d40; baseClass = UITableViewCell; frame = (0 202; 266 44); text = 'Toggle All'; autoresize = W; layer = <CALayer: 0x10ba6c00>>
   |    |    |    |    |    |    |    |    | <UITableViewCellScrollView: 0x10ba6ed0; frame = (0 0; 266 44); autoresize = W+H; gestureRecognizers = <NSArray: 0x10ba7160>; layer = <CALayer: 0x10ba70a0>; contentOffset: {0, 0}>
   |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10b67390; frame = (0 0; 266 44); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10b67480>> - (null)
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0x10ba7350; frame = (0 0; 266 44); gestureRecognizers = <NSArray: 0x10ba7560>; layer = <CALayer: 0x10ba73c0>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0x10ba75b0; frame = (15 0; 236 44); text = 'Toggle All'; userInteractionEnabled = NO; layer = <CALayer: 0x10ba7660>>
   |    |    |    |    |    |    |    | <UITableViewCell: 0x10ba6030; frame = (0 164; 266 38); text = 'Categories'; autoresize = W; layer = <CALayer: 0x10ba5fa0>>
   |    |    |    |    |    |    |    |    | <UITableViewCellScrollView: 0x10ba61c0; frame = (0 0; 266 38); autoresize = W+H; gestureRecognizers = <NSArray: 0x10ba6450>; layer = <CALayer: 0x10ba6390>; contentOffset: {0, 0}>
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0x10ba6640; frame = (0 0; 266 38); gestureRecognizers = <NSArray: 0x10ba6850>; layer = <CALayer: 0x10ba66b0>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0x10ba68a0; frame = (15 0; 236 38); text = 'Categories'; userInteractionEnabled = NO; layer = <CALayer: 0x10ba6950>>
   |    |    |    |    |    |    |    | <SegmentedControlCell: 0x10b9afd0; baseClass = UITableViewCell; frame = (0 120; 266 44); autoresize = W; layer = <CALayer: 0x10b9b200>>
   |    |    |    |    |    |    |    |    | <UITableViewCellScrollView: 0x10b9b430; frame = (0 0; 266 44); autoresize = W+H; gestureRecognizers = <NSArray: 0x10b9b6c0>; layer = <CALayer: 0x10b9b600>; contentOffset: {0, 0}>
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0x10b9b8b0; frame = (0 0; 266 44); gestureRecognizers = <NSArray: 0x10b9bac0>; layer = <CALayer: 0x10b9b920>>
   |    |    |    |    |    |    |    |    |    |    | <UISegmentedControl: 0x10b9bd30; frame = (0 0; 266 44); opaque = NO; layer = <CALayer: 0x10b9be70>>
   |    |    |    |    |    |    |    |    |    |    |    | <UISegment: 0x10ba4ef0; frame = (178 0; 88 44); opaque = NO; layer = <CALayer: 0x10ba4e40>> - Room
   |    |    |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10ba5630; frame = (88 0; 2 44); alpha = 0; opaque = NO; autoresize = LM; userInteractionEnabled = NO; tag = -1030; layer = <CALayer: 0x10ba56b0>> - (null)
   |    |    |    |    |    |    |    |    |    |    |    |    | <UISegmentLabel: 0x10bcede0; frame = (13.5 11; 43 20); text = 'Room'; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10bcee90>>
   |    |    |    |    |    |    |    |    |    |    |    | <UISegment: 0x10ba43f0; frame = (89 0; 87 44); opaque = NO; layer = <CALayer: 0x10ba43b0>> - Category
   |    |    |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10ba4c50; frame = (87 0; 2 44); opaque = NO; autoresize = LM; userInteractionEnabled = NO; tag = -1030; layer = <CALayer: 0x10ba4cd0>> - (null)
   |    |    |    |    |    |    |    |    |    |    |    |    | <UISegmentLabel: 0x10bcfe40; frame = (10.5 11; 66 20); text = 'Category'; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10bd0400>>
   |    |    |    |    |    |    |    |    |    |    |    | <UISegment: 0x10ba0fb0; frame = (0 0; 87 44); opaque = NO; layer = <CALayer: 0x10ba1130>> - Time
   |    |    |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10ba3ec0; frame = (87 0; 2 44); opaque = NO; autoresize = LM; userInteractionEnabled = NO; tag = -1030; layer = <CALayer: 0x10ba3cf0>> - (null)
   |    |    |    |    |    |    |    |    |    |    |    |    | <UISegmentLabel: 0x10bce190; frame = (35 11; 35 20); text = 'Time'; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10bce240>>
   |    |    |    |    |    |    |    | <UITableViewCell: 0x10b9a210; frame = (0 82; 266 38); text = 'Order By'; autoresize = W; layer = <CALayer: 0x10b99870>>
   |    |    |    |    |    |    |    |    | <UITableViewCellScrollView: 0x10b9a3a0; frame = (0 0; 266 38); autoresize = W+H; gestureRecognizers = <NSArray: 0x10b9a5f0>; layer = <CALayer: 0x10b9a570>; contentOffset: {0, 0}>
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0x10b9a7e0; frame = (0 0; 266 38); gestureRecognizers = <NSArray: 0x10b9a9f0>; layer = <CALayer: 0x10b9a850>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0x10b9aa40; frame = (15 0; 236 38); text = 'Order By'; userInteractionEnabled = NO; layer = <CALayer: 0x10b9aaf0>>
   |    |    |    |    |    |    |    | <CustomButtonCell: 0x10b95850; baseClass = UITableViewCell; frame = (0 38; 266 44); text = 'All Days'; autoresize = W; layer = <CALayer: 0x10b95a80>>
   |    |    |    |    |    |    |    |    | <UITableViewCellScrollView: 0x10b95cb0; frame = (0 0; 266 44); autoresize = W+H; gestureRecognizers = <NSArray: 0x10b95f40>; layer = <CALayer: 0x10b95e80>; contentOffset: {0, 0}>
   |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10b63a10; frame = (0 0; 266 44); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10b63ac0>> - (null)
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0x10b96130; frame = (0 0; 266 44); gestureRecognizers = <NSArray: 0x10b96340>; layer = <CALayer: 0x10b961a0>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0x10b96390; frame = (15 0; 236 44); text = 'All Days'; userInteractionEnabled = NO; layer = <CALayer: 0x10b96440>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10b638b0; frame = (224 15; 18 14); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10b63850>> - (null)
   |    |    |    |    |    |    |    | <UITableViewCell: 0x10b948b0; frame = (0 0; 266 38); text = 'Dates'; autoresize = W; layer = <CALayer: 0x10b94770>>
   |    |    |    |    |    |    |    |    | <UITableViewCellScrollView: 0x10b94a40; frame = (0 0; 266 38); autoresize = W+H; gestureRecognizers = <NSArray: 0x10b94cd0>; layer = <CALayer: 0x10b94c10>; contentOffset: {0, 0}>
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0x10b94ec0; frame = (0 0; 266 38); gestureRecognizers = <NSArray: 0x10b950d0>; layer = <CALayer: 0x10b94f30>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0x10b95120; frame = (15 0; 236 38); text = 'Dates'; userInteractionEnabled = NO; layer = <CALayer: 0x10b951d0>>
   |    |    |    |    |    |    |    | <UITableViewCell: 0x10b93ea0; frame = (0 0; 266 0); autoresize = W; layer = <CALayer: 0x10b94030>>
   |    |    |    |    |    |    |    |    | <UITableViewCellScrollView: 0x10b94060; frame = (0 0; 266 0); autoresize = W+H; gestureRecognizers = <NSArray: 0x10b942d0>; layer = <CALayer: 0x10b94230>; contentOffset: {0, 0}>
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0x10b944c0; frame = (0 0; 266 0); gestureRecognizers = <NSArray: 0x10b946d0>; layer = <CALayer: 0x10b94530>>
   |    |    |    |    |    |    |    | <UITableViewCell: 0x10b93320; frame = (0 0; 266 0); autoresize = W; layer = <CALayer: 0x10b934b0>>
   |    |    |    |    |    |    |    |    | <UITableViewCellScrollView: 0x10b934e0; frame = (0 0; 266 0); autoresize = W+H; gestureRecognizers = <NSArray: 0x10b93770>; layer = <CALayer: 0x10b936b0>; contentOffset: {0, 0}>
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0x10b93960; frame = (0 0; 266 0); gestureRecognizers = <NSArray: 0x10b93b70>; layer = <CALayer: 0x10b939d0>>
   |    |    |    |    |    |    |    | <CategorySelectionCell: 0xbb9e3b0; baseClass = UITableViewCell; frame = (0 246; 266 44); text = 'Communication'; autoresize = W; layer = <CALayer: 0xbb9f790>>
   |    |    |    |    |    |    |    |    | <UITableViewCellScrollView: 0xbb9f9c0; frame = (0 0; 266 44); autoresize = W+H; gestureRecognizers = <NSArray: 0xbb9fc30>; layer = <CALayer: 0xbb9fb90>; contentOffset: {0, 0}>
   |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10b3b070; frame = (0 0; 266 44); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10b95b00>> - (null)
   |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10b32560; frame = (0 -0.5; 266 45); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xbadc9a0>> - (null)
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0xbb9fe20; frame = (0 0; 266 44); opaque = NO; gestureRecognizers = <NSArray: 0xbba0030>; layer = <CALayer: 0xbb9fe90>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0xbba0080; frame = (65 0; 186 44); text = 'Communication'; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xbba0130>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10bbabf0; frame = (25 7; 30 30); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10bbac90>> - (null)
   |    |    |    |    |    |    |    | <CategorySelectionCell: 0xbba2360; baseClass = UITableViewCell; frame = (0 290; 266 44); text = 'Entertainment'; autoresize = W; layer = <CALayer: 0xbba22f0>>
   |    |    |    |    |    |    |    |    | <UITableViewCellScrollView: 0xbba24f0; frame = (0 0; 266 44); autoresize = W+H; gestureRecognizers = <NSArray: 0xbba2720>; layer = <CALayer: 0xbba2320>; contentOffset: {0, 0}>
   |    |    |    |    |    |    |    |    |    | <UIImageView: 0xbadc850; frame = (0 0; 266 44); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10ba2ce0>> - (null)
   |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10b7e4a0; frame = (0 -0.5; 266 45); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10b82c30>> - (null)
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0xbba2910; frame = (0 0; 266 44); opaque = NO; gestureRecognizers = <NSArray: 0xbba2b20>; layer = <CALayer: 0xbba2980>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0xbba2b70; frame = (65 0; 186 44); text = 'Entertainment'; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xbba2c20>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10bbb040; frame = (25 7; 30 30); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10bbb0e0>> - (null)
   |    |    |    |    |    |    |    | <CategorySelectionCell: 0xbba6110; baseClass = UITableViewCell; frame = (0 334; 266 44); text = 'Event Technology'; autoresize = W; layer = <CALayer: 0xbba6090>>
   |    |    |    |    |    |    |    |    | <UITableViewCellScrollView: 0xbba62a0; frame = (0 0; 266 44); autoresize = W+H; gestureRecognizers = <NSArray: 0xbba64b0>; layer = <CALayer: 0xbba2ee0>; contentOffset: {0, 0}>
   |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10b9d5f0; frame = (0 0; 266 44); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10b9d6c0>> - (null)
   |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10b9d750; frame = (0 -0.5; 266 45); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10b9d840>> - (null)
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0xbba66a0; frame = (0 0; 266 44); opaque = NO; gestureRecognizers = <NSArray: 0xbba68b0>; layer = <CALayer: 0xbba6710>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0xbba6900; frame = (65 0; 186 44); text = 'Event Technology'; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xbba69b0>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10bbb450; frame = (25 7; 30 30); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10bbb4f0>> - (null)
   |    |    |    |    |    |    |    | <CategorySelectionCell: 0xbba9ea0; baseClass = UITableViewCell; frame = (0 378; 266 44); text = 'Exhibitor Mgmt.'; autoresize = W; layer = <CALayer: 0xbba9e20>>
   |    |    |    |    |    |    |    |    | <UITableViewCellScrollView: 0xbbaa030; frame = (0 0; 266 44); autoresize = W+H; gestureRecognizers = <NSArray: 0xbbaa240>; layer = <CALayer: 0xbba6c70>; contentOffset: {0, 0}>
   |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10bb9110; frame = (0 0; 266 44); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10bb9220>> - (null)
   |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10bb92c0; frame = (0 -0.5; 266 45); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10bb93b0>> - (null)
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0xbbaa430; frame = (0 0; 266 44); opaque = NO; gestureRecognizers = <NSArray: 0xbbaa640>; layer = <CALayer: 0xbbaa4a0>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0xbbaa690; frame = (65 0; 186 44); text = 'Exhibitor Mgmt.'; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xbbaa740>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10bbb860; frame = (25 7; 30 30); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10bbb900>> - (null)
   |    |    |    |    |    |    | <UIView: 0x10bbab90; frame = (0 365; 266 15); autoresize = W; layer = <CALayer: 0x10bb7b30>>
   |    |    |    |    |    |    | <UIImageView: 0x10b6cca0; frame = (0 376.5; 266 3.5); alpha = 0; opaque = NO; autoresize = TM; userInteractionEnabled = NO; layer = <CALayer: 0x10b6cae0>> - (null)
   |    |    |    |    |    |    | <UIImageView: 0x10bc4850; frame = (262.5 -20; 3.5 400); alpha = 0; opaque = NO; autoresize = LM; userInteractionEnabled = NO; layer = <CALayer: 0x10bc4920>> - (null)
   |    |    |    |    |    | <UIImageView: 0x10b6d9b0; frame = (266 0; 3 460); autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x10b6da30>> - (null)
   |    |    |    |    |    | <UIImageView: 0x10b8eba0; frame = (0 0; 266 44); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10b8dd90>> - (null)
   |    |    |    |    |    |    | <UILabel: 0x10baaa50; frame = (0 0; 266 44); text = ' '; userInteractionEnabled = NO; layer = <CALayer: 0x10b94860>>
   |    |    |    |    |    | <UIButton: 0x10ba47c0; frame = (70 6; 140 44); opaque = NO; layer = <CALayer: 0x10b9ded0>>
   |    |    |    |    |    |    | <UIImageView: 0x10bc9850; frame = (0 0; 140 44); clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10bc86d0>> - (null)
   |    |    |    |    |    |    | <UIButtonLabel: 0x10b725e0; frame = (50 11; 40 22); text = 'Filter'; clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10ba45e0>>
   |    |    |    |    |    | <UITableView: 0xc215a00; frame = (0 44; 266 400); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x10b6c680>; layer = <CALayer: 0x10b6c220>; contentOffset: {0, 0}>
   |    |    |    |    |    |    | <UIView: 0x10b88340; frame = (0 -400; 266 400); hidden = YES; autoresize = W; layer = <CALayer: 0x10b88040>>
   |    |    |    |    |    |    | <UITableViewWrapperView: 0x10b6c980; frame = (0 0; 266 400); autoresize = W+H; layer = <CALayer: 0x10b6c9f0>>
   |    |    |    |    |    |    |    | <SessionTableViewCell: 0xbb9d2d0; baseClass = UITableViewCell; frame = (0 364; 266 76); autoresize = W; layer = <CALayer: 0xbb9d210>>
   |    |    |    |    |    |    |    |    | <UITableViewCellScrollView: 0xbb9d470; frame = (0 0; 266 76); autoresize = W+H; gestureRecognizers = <NSArray: 0xbb9d700>; layer = <CALayer: 0xbb9d640>; contentOffset: {0, 0}>
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0xbb9b900; frame = (0 0; 266 76); gestureRecognizers = <NSArray: 0xbb9bac0>; layer = <CALayer: 0xbb9d8f0>>
   |    |    |    |    |    |    |    |    |    |    | <MTLabel: 0xbb9bb70; frame = (20 10; 250 40); text = 'Effortless CEU Session Ma...'; opaque = NO; layer = <CALayer: 0xbb9bc10>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0xbb9c050; frame = (20 56; 58.5181 12); text = 'Bayside C • '; userInteractionEnabled = NO; layer = <CALayer: 0xbb9c100>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0xbb9c530; frame = (78.5181 56; 129.216 12); text = 'Mar. 7 1:00pm - 2:00pm'; userInteractionEnabled = NO; layer = <CALayer: 0xbb9c630>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0xbb9f1b0; frame = (0 74; 266 2); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xbb9f2a0>> - (null)
   |    |    |    |    |    |    |    | <SessionTableViewCell: 0xbb9a0b0; baseClass = UITableViewCell; frame = (0 284; 266 60); autoresize = W; layer = <CALayer: 0xbb99ff0>>
   |    |    |    |    |    |    |    |    | <UITableViewCellScrollView: 0xbb9a250; frame = (0 0; 266 60); autoresize = W+H; gestureRecognizers = <NSArray: 0xbb9a4e0>; layer = <CALayer: 0xbb9a420>; contentOffset: {0, 0}>
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0xbb9a6d0; frame = (0 0; 266 60); gestureRecognizers = <NSArray: 0xbb9a8e0>; layer = <CALayer: 0xbb9a740>>
   |    |    |    |    |    |    |    |    |    |    | <MTLabel: 0xbb9a990; frame = (20 12; 250 20); text = 'Lunch - Day 1'; opaque = NO; layer = <CALayer: 0xbb9aa30>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0xbb9ae70; frame = (20 38; 104.457 12); text = 'Main Dining Room • '; userInteractionEnabled = NO; layer = <CALayer: 0xbb9af20>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0xbb9b450; frame = (124.457 38; 135.888 12); text = 'Mar. 7 12:00pm - 1:00pm'; userInteractionEnabled = NO; layer = <CALayer: 0xbb9b560>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0xbb9d0b0; frame = (0 58; 266 2); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xbb9d1a0>> - (null)
   |    |    |    |    |    |    |    | <SessionTableViewCell: 0xbb99350; baseClass = UITableViewCell; frame = (0 204; 266 60); autoresize = W; layer = <CALayer: 0xbb99290>>
   |    |    |    |    |    |    |    |    | <UITableViewCellScrollView: 0xbb994f0; frame = (0 0; 266 60); autoresize = W+H; gestureRecognizers = <NSArray: 0xbb99780>; layer = <CALayer: 0xbb996c0>; contentOffset: {0, 0}>
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0xbb97990; frame = (0 0; 266 60); gestureRecognizers = <NSArray: 0xbb97b40>; layer = <CALayer: 0xbb99970>>
   |    |    |    |    |    |    |    |    |    |    | <MTLabel: 0xbb97bf0; frame = (20 12; 250 20); text = 'Keynote Address'; opaque = NO; layer = <CALayer: 0xbb97c90>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0xbb980d0; frame = (20 38; 90.7769 12); text = 'Grand Ballroom • '; userInteractionEnabled = NO; layer = <CALayer: 0xbb98180>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0xbb985b0; frame = (110.777 38; 135.216 12); text = 'Mar. 7 9:00am - 12:00pm'; userInteractionEnabled = NO; layer = <CALayer: 0xbb986b0>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0xbb99e90; frame = (0 58; 266 2); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xbb99f80>> - (null)
   |    |    |    |    |    |    |    | <SessionTableViewCell: 0xbb95890; baseClass = UITableViewCell; frame = (0 124; 266 60); autoresize = W; layer = <CALayer: 0xbb95830>>
   |    |    |    |    |    |    |    |    | <UITableViewCellScrollView: 0xbb95a30; frame = (0 0; 266 60); autoresize = W+H; gestureRecognizers = <NSArray: 0xbb95cc0>; layer = <CALayer: 0xbb95c00>; contentOffset: {0, 0}>
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0xbb95eb0; frame = (0 0; 266 60); gestureRecognizers = <NSArray: 0xbb96140>; layer = <CALayer: 0xbb95fa0>>
   |    |    |    |    |    |    |    |    |    |    | <MTLabel: 0xbb961f0; frame = (20 12; 250 20); text = 'Welcome / Meet and Greet'; opaque = NO; layer = <CALayer: 0xbb96310>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0xbb96750; frame = (20 38; 69.0776 12); text = 'Front Foyer • '; userInteractionEnabled = NO; layer = <CALayer: 0xbb96800>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0xbb975e0; frame = (89.0776 38; 127.872 12); text = 'Mar. 7 8:00am - 9:00am'; userInteractionEnabled = NO; layer = <CALayer: 0xbb976c0>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0xbb99130; frame = (0 58; 266 2); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xbb99220>> - (null)
   |    |    |    |    |    |    |    | <SessionTableViewCell: 0xbb94a10; baseClass = UITableViewCell; frame = (0 64; 266 60); autoresize = W; layer = <CALayer: 0xbb92f40>>
   |    |    |    |    |    |    |    |    | <UITableViewCellScrollView: 0xbb94d30; frame = (0 0; 266 60); autoresize = W+H; gestureRecognizers = <NSArray: 0xbb912d0>; layer = <CALayer: 0xbb92ff0>; contentOffset: {0, 0}>
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0xbb939a0; frame = (0 0; 266 60); gestureRecognizers = <NSArray: 0xbb93bf0>; layer = <CALayer: 0xbb93a50>>
   |    |    |    |    |    |    |    |    |    |    | <MTLabel: 0xbb93fc0; frame = (20 12; 250 20); text = 'Registration Desk - Day 1'; opaque = NO; layer = <CALayer: 0xbb94100>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0xbb946c0; frame = (20 38; 69.0776 12); text = 'Front Foyer • '; userInteractionEnabled = NO; layer = <CALayer: 0xbb94770>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0xbb94fd0; frame = (89.0776 38; 134.544 12); text = 'Mar. 7 8:00am - 10:00am'; userInteractionEnabled = NO; layer = <CALayer: 0xbb95080>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0xbb97250; frame = (0 58; 266 2); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xbb972d0>> - (null)
   |    |    |    |    |    |    | <UISearchBar: 0x10b6feb0; frame = (0 0; 266 44); text = ''; autoresize = W; gestureRecognizers = <NSArray: 0x10b704a0>; layer = <CALayer: 0x10b70040>>
   |    |    |    |    |    |    |    | <UIView: 0x10b70270; frame = (0 0.5; 266 43.5); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x10b702d0>>
   |    |    |    |    |    |    |    |    | <UISearchBarBackground: 0x10b707a0; frame = (0 0; 266 44); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10b708f0>> - (null)
   |    |    |    |    |    |    |    |    | <UISearchBarTextField: 0x10b736a0; frame = (8 5; 250 33); text = ''; clipsToBounds = YES; opaque = NO; gestureRecognizers = <NSArray: 0x10bc36c0>; layer = <CALayer: 0x10b72d60>>
   |    |    |    |    |    |    |    |    |    | <UITextFieldBorderView: 0x10b7bc60; frame = (0 0; 250 33); opaque = NO; layer = <CALayer: 0x10b7bd70>>
   |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10b76390; frame = (92.5 9.5; 12.5 12.5); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10b76410>> - Search
   |    |    |    |    |    |    |    |    |    | <UISearchBarTextFieldLabel: 0x10b7c580; frame = (112.5 0; 137.5 33); text = 'Search'; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10b7c6d0>>
   |    |    |    |    |    |    |    |    | <UIView: 0xbb920f0; frame = (0 -1; 266 1); layer = <CALayer: 0xbb92150>>
   |    |    |    |    |    |    | <UIImageView: 0x10b6c450; frame = (0 396.5; 266 3.5); alpha = 0; opaque = NO; autoresize = TM; userInteractionEnabled = NO; layer = <CALayer: 0x10b6c290>> - (null)
   |    |    |    |    |    |    | <SessionTableHeaderView: 0x10bd1d30; frame = (0 44; 266 20); autoresize = W; layer = <CALayer: 0x10bd1db0>>
   |    |    |    |    |    |    |    | <UIImageView: 0x10bd1ec0; frame = (0 0; 266 20); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10bd1e50>> - (null)
   |    |    |    |    |    |    |    | <UILabel: 0x10bd2020; frame = (10 0; 246 20); userInteractionEnabled = NO; layer = <CALayer: 0x10bd1f70>>
   |    |    |    |    |    |    |    | <UILabel: 0x10bd2650; frame = (10 0; 236 20); text = 'Mar. 7 8:00am'; userInteractionEnabled = NO; layer = <CALayer: 0x10bd2290>>
   |    |    |    |    |    |    | <SessionTableHeaderView: 0x10bd1830; frame = (0 184; 266 20); autoresize = W; layer = <CALayer: 0x10bd18b0>>
   |    |    |    |    |    |    |    | <UIImageView: 0x10bd23a0; frame = (0 0; 266 20); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10bd2420>> - (null)
   |    |    |    |    |    |    |    | <UILabel: 0x10bd2530; frame = (10 0; 246 20); userInteractionEnabled = NO; layer = <CALayer: 0x10bd25e0>>
   |    |    |    |    |    |    |    | <UILabel: 0x10bcead0; frame = (10 0; 236 20); text = 'Mar. 7 9:00am'; userInteractionEnabled = NO; layer = <CALayer: 0x10bd2db0>>
   |    |    |    |    |    |    | <SessionTableHeaderView: 0x10bd3720; frame = (0 264; 266 20); autoresize = W; layer = <CALayer: 0x10bd37a0>>
   |    |    |    |    |    |    |    | <UIImageView: 0x10bd3890; frame = (0 0; 266 20); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10bd3820>> - (null)
   |    |    |    |    |    |    |    | <UILabel: 0x10bd39f0; frame = (10 0; 246 20); userInteractionEnabled = NO; layer = <CALayer: 0x10bd3930>>
   |    |    |    |    |    |    |    | <UILabel: 0x10bd48c0; frame = (10 0; 236 20); text = 'Mar. 7 12:00pm'; userInteractionEnabled = NO; layer = <CALayer: 0x10bd4970>>
   |    |    |    |    |    |    | <SessionTableHeaderView: 0xbb67e40; frame = (0 344; 266 20); autoresize = W; layer = <CALayer: 0xbbae740>>
   |    |    |    |    |    |    |    | <UIImageView: 0xbb97180; frame = (0 0; 266 20); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xbbae220>> - (null)
   |    |    |    |    |    |    |    | <UILabel: 0xbba2d90; frame = (10 0; 246 20); userInteractionEnabled = NO; layer = <CALayer: 0xbbae250>>
   |    |    |    |    |    |    |    | <UILabel: 0x10bd1510; frame = (10 0; 236 20); text = 'Mar. 7 1:00pm'; userInteractionEnabled = NO; layer = <CALayer: 0x10bd15c0>>
   |    |    |    |    |    |    | <UIImageView: 0x10bc4f50; frame = (262.5 0; 3.5 400); alpha = 0; opaque = NO; autoresize = LM; userInteractionEnabled = NO; layer = <CALayer: 0x10bc5020>> - (null)

...

2 个答案:

答案 0 :(得分:0)

我收集您发布的代码是您创建的自定义UIView子类的实现的一部分吗?

为什么要操纵超级视图的框架?这看起来并不正确。

对于给定视图,其边界位于其局部坐标系中,并且视图的框架位于父视图的坐标系中。操作视图的frame.origin将视图移动到其父视图中。操纵视图的superview.frame将在 ITS 超级视图中移动超视图,这看起来不正确,可能会产生意想不到的副作用。

答案 1 :(得分:0)

因为我永远无法确定为什么其中一个兄弟视图(在我的情况下是parentViewController.rightDrawer)捕获了所有的触摸而不是覆盖,我只是在处理并提出了这个解决方案:

在显示叠加层时,我会在视图中添加一个UITapGestureRecognizer,以便继续抓取触摸:

UITapGestureRecognizer *tap  =  [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleTap:)];

tap.delegate = self;
[self.parentViewController.rightDrawer addGestureRecognizer:tap];

然后让我的handleTap函数翻译CGPoints并激活相应的代码:

- (void)handleTap:(UITapGestureRecognizer *)sender
{
    if (sender.state == UIGestureRecognizerStateEnded)
    {
        CGPoint touchPoint = [sender.view convertPoint:[sender locationInView:[sender.view self]] toView:self.scanOverlay];
        if (CGRectContainsPoint(self.bottomScanButton.frame, touchPoint)) {
            [self bottomScanButtonPressed:self.bottomScanButton];
        }
        else if (CGRectContainsPoint(self.scanOverlay.closeButton.frame, touchPoint)) {
            [self hideScanOverlayAnimated:YES didScan:NO];
        }
        else if (CGRectContainsPoint(self.scanOverlay.modeButton.frame, touchPoint)) {
            [self.scanOverlay modeButtonPressed:self.scanOverlay.modeButton];
        }
    }
}

由于我只有三个具有任何用户交互的按钮,我只是检测转换后的接触点是否正在触摸我的任何控件并激发正确的逻辑。

然后在隐藏我的叠加层时,我删除了点击识别器:

// Remove the tap recognizer that was added to catch the taps coming from the right drawer
for (UIGestureRecognizer *recognizer in self.parentViewController.rightDrawer.gestureRecognizers) {

    if([recognizer isKindOfClass:[UITapGestureRecognizer class]]) {
        [self.parentViewController.rightDrawer removeGestureRecognizer:recognizer];
    }
}

我本可以创建一个iVar并且只删除一个识别器,但由于我没有任何其他人,我只需要修改任何UITapGestureRecognizer。

Kludgy,但我有截止日期。不幸的是,这就是生活。必须在下一个重构器上捕获它。