Skip to content
This repository was archived by the owner on Nov 17, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
.DS_Store
*.xcuserdatad
*xcworkspace*
# Xcode
build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xcworkspace
!default.xcworkspace
xcuserdata
profile
*.moved-aside
DerivedData
5 changes: 5 additions & 0 deletions PSPushPopPressView.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@
UITapGestureRecognizer* tapRecognizer_;
UILongPressGestureRecognizer* doubleTouchRecognizer;
UIPanGestureRecognizer* panRecognizer_;
UISwipeGestureRecognizer* swipeRecognizer_;
CGAffineTransform scaleTransform_;
CGAffineTransform rotateTransform_;
CGAffineTransform panTransform_;
CGRect initialFrame_;
NSInteger initialIndex_;
BOOL allowSingleTapSwitch_;
BOOL allowFullscreenInteraction_;
BOOL fullscreen_;
BOOL ignoreStatusBar_;
BOOL keepShadow_;
Expand All @@ -69,6 +71,9 @@
/// allow mode switching via single tap. Defaults to YES.
@property (nonatomic, assign) BOOL allowSingleTapSwitch;

/// allow user interaction in fullscreen. Defaults to YES.
@property (nonatomic, assign) BOOL allowFullscreenInteraction;

/// if true, [UIScreen mainScreen] is used for coordinates (vs rootView)
@property (nonatomic, assign) BOOL ignoreStatusBar;

Expand Down
38 changes: 38 additions & 0 deletions PSPushPopPressView.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ @implementation PSPushPopPressView
@synthesize fullscreen = fullscreen_;
@synthesize initialFrame = initialFrame_;
@synthesize allowSingleTapSwitch = allowSingleTapSwitch_;
@synthesize allowFullscreenInteraction = allowFullscreenInteraction_;
@synthesize ignoreStatusBar = ignoreStatusBar_;
@synthesize keepShadow = keepShadow_;

Expand All @@ -54,6 +55,7 @@ - (id)initWithFrame:(CGRect)frame_ {
initialFrame_ = frame_;
initialIndex_ = 0;
allowSingleTapSwitch_ = YES;
allowFullscreenInteraction_ = YES;
keepShadow_ = NO;

UIPinchGestureRecognizer* pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchPanRotate:)];
Expand Down Expand Up @@ -94,6 +96,14 @@ - (id)initWithFrame:(CGRect)frame_ {
doubleTouchRecognizer.numberOfTouchesRequired = 2;
doubleTouchRecognizer.minimumPressDuration = 0.f;
[self addGestureRecognizer:doubleTouchRecognizer];

swipeRecognizer_ = [[UISwipeGestureRecognizer alloc] initWithTarget:self action: @selector(swipe:)];
swipeRecognizer_.delegate = self;
swipeRecognizer_.cancelsTouchesInView = NO;
swipeRecognizer_.delaysTouchesBegan = NO;
swipeRecognizer_.delaysTouchesEnded = NO;
swipeRecognizer_.direction = UISwipeGestureRecognizerDirectionRight | UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionUp | UISwipeGestureRecognizerDirectionDown;
[self addGestureRecognizer:swipeRecognizer_];

self.layer.shadowRadius = 15.0f;
self.layer.shadowOffset = CGSizeMake(5.0f, 5.0f);
Expand Down Expand Up @@ -420,6 +430,8 @@ - (void)adjustAnchorPointForGestureRecognizer:(UIGestureRecognizer *)gestureReco
}

- (void)pinchPanRotate:(UIGestureRecognizer *)gesture {
if (self.isFullscreen && !self.allowFullscreenInteraction)
return;

switch (gesture.state) {
case UIGestureRecognizerStateBegan: {
Expand Down Expand Up @@ -452,6 +464,9 @@ - (void)pinchPanRotate:(UIGestureRecognizer *)gesture {
}

- (void)doubleTapped:(UITapGestureRecognizer *)gesture {
if (self.isFullscreen && !self.allowFullscreenInteraction)
return;

switch (gesture.state) {
case UIGestureRecognizerStateBegan: {
self.beingDragged = YES;
Expand Down Expand Up @@ -489,6 +504,9 @@ - (void)doubleTapped:(UITapGestureRecognizer *)gesture {
}

- (void)tap:(UITapGestureRecognizer *)tap {
if (self.isFullscreen && !self.allowFullscreenInteraction)
return;

if (self.allowSingleTapSwitch) {
if (tap.state == UIGestureRecognizerStateEnded) {
if ([self.pushPopPressViewDelegate respondsToSelector: @selector(pushPopPressViewDidReceiveTap:)]) {
Expand All @@ -512,7 +530,27 @@ - (void)tap:(UITapGestureRecognizer *)tap {
}
}

- (void)swipe:(UISwipeGestureRecognizer *)swipe {
if (self.isFullscreen && !self.allowFullscreenInteraction)
return;

if (swipe.state == UIGestureRecognizerStateEnded) {

if (self.isFullscreen) {
if ([self.pushPopPressViewDelegate respondsToSelector: @selector(pushPopPressViewShouldAllowTapToAnimateToOriginalFrame:)]) {
if ([self.pushPopPressViewDelegate pushPopPressViewShouldAllowTapToAnimateToOriginalFrame: self] == NO) return;
}

[self moveToOriginalFrameAnimated:YES];
}
}
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
// if in fullscreen and fullscreen interaction is disabled, allow simultaneous recognition
if (self.isFullscreen && !self.allowFullscreenInteraction)
return YES;

// if the gesture recognizers's view isn't one of our pieces, don't allow simultaneous recognition
if (gestureRecognizer.view != self)
return NO;
Expand Down
16 changes: 15 additions & 1 deletion PSPushPopPressView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
78A918351478122900EFFC4D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0420;
LastUpgradeCheck = 0460;
};
buildConfigurationList = 78A918381478122900EFFC4D /* Build configuration list for PBXProject "PSPushPopPressView" */;
compatibilityVersion = "Xcode 3.2";
Expand Down Expand Up @@ -151,6 +151,10 @@
armv6,
);
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
Expand All @@ -160,9 +164,11 @@
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_THUMB_SUPPORT = NO;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
SDKROOT = iphoneos;
Expand All @@ -179,11 +185,17 @@
armv6,
);
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_THUMB_SUPPORT = NO;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
SDKROOT = iphoneos;
Expand All @@ -196,6 +208,7 @@
buildSettings = {
DSTROOT = /tmp/PSPushPopPressView.dst;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_THUMB_SUPPORT = NO;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -207,6 +220,7 @@
buildSettings = {
DSTROOT = /tmp/PSPushPopPressView.dst;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_THUMB_SUPPORT = NO;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down