Skip to content

Commit 993a18d

Browse files
committed
Allocate topViewSnapshot ahead of time
- Fixes tapping gesture from disappearing when presenting modal, rotating, and then dismissing.
1 parent c446607 commit 993a18d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ - (void)viewDidLoad
172172
self.resetStrategy = ECTapping | ECPanning;
173173
self.resetTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(resetTopView)];
174174
_panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(updateTopViewHorizontalCenterWithRecognizer:)];
175+
176+
self.topViewSnapshot = [[UIView alloc] initWithFrame:self.topView.bounds];
177+
[self.topViewSnapshot setAutoresizingMask:self.autoResizeToFillScreen];
178+
[self.topViewSnapshot addGestureRecognizer:self.resetTapGesture];
175179
}
176180

177181
- (void)viewWillAppear:(BOOL)animated
@@ -400,18 +404,15 @@ - (void)topViewHorizontalCenterDidChange:(CGFloat)newHorizontalCenter
400404
- (void)addTopViewSnapshot
401405
{
402406
if (!self.topViewSnapshot.superview && !self.shouldAllowUserInteractionsWhenAnchored) {
403-
self.topViewSnapshot = [[UIView alloc] initWithFrame:self.topView.bounds];
404407
topViewSnapshot.layer.contents = (id)[UIImage imageWithUIView:self.topView].CGImage;
405408
[self.topView addSubview:self.topViewSnapshot];
406-
[self.topViewSnapshot addGestureRecognizer:self.resetTapGesture];
407409
}
408410
}
409411

410412
- (void)removeTopViewSnapshot
411413
{
412414
if (self.topViewSnapshot.superview) {
413415
[self.topViewSnapshot removeFromSuperview];
414-
topViewSnapshot = nil;
415416
}
416417
}
417418

0 commit comments

Comments
 (0)