diff --git a/.gitignore b/.gitignore index 6256b64..5ba3b59 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/PSPushPopPressView.h b/PSPushPopPressView.h index 57b307e..2a5f00c 100755 --- a/PSPushPopPressView.h +++ b/PSPushPopPressView.h @@ -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_; @@ -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; diff --git a/PSPushPopPressView.m b/PSPushPopPressView.m index 067542a..8a04d83 100755 --- a/PSPushPopPressView.m +++ b/PSPushPopPressView.m @@ -33,6 +33,7 @@ @implementation PSPushPopPressView @synthesize fullscreen = fullscreen_; @synthesize initialFrame = initialFrame_; @synthesize allowSingleTapSwitch = allowSingleTapSwitch_; +@synthesize allowFullscreenInteraction = allowFullscreenInteraction_; @synthesize ignoreStatusBar = ignoreStatusBar_; @synthesize keepShadow = keepShadow_; @@ -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:)]; @@ -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); @@ -420,6 +430,8 @@ - (void)adjustAnchorPointForGestureRecognizer:(UIGestureRecognizer *)gestureReco } - (void)pinchPanRotate:(UIGestureRecognizer *)gesture { + if (self.isFullscreen && !self.allowFullscreenInteraction) + return; switch (gesture.state) { case UIGestureRecognizerStateBegan: { @@ -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; @@ -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:)]) { @@ -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; diff --git a/PSPushPopPressView.xcodeproj/project.pbxproj b/PSPushPopPressView.xcodeproj/project.pbxproj index 024ac4c..69c39f8 100644 --- a/PSPushPopPressView.xcodeproj/project.pbxproj +++ b/PSPushPopPressView.xcodeproj/project.pbxproj @@ -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"; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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;