Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adjust size of the area to be touched for dismissing popupview.

  • Loading branch information...
commit c73e8dc83d5d0547dc0f8469d8e43391a7be6dd6 1 parent 075f046
@sonsongithub authored
View
11 PopupViewTest.xcodeproj/project.pbxproj
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 45;
+ objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
@@ -11,7 +11,6 @@
1410EF521440711D00C034A5 /* SNPopupView+UsingPrivateMethod.m in Sources */ = {isa = PBXBuildFile; fileRef = 1410EF511440711D00C034A5 /* SNPopupView+UsingPrivateMethod.m */; };
1427AFDF127F02840082F84D /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1427AFDE127F02840082F84D /* QuartzCore.framework */; };
143F9FFF139756270008ACE0 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 143F9FF5139756270008ACE0 /* main.m */; };
- 143FA001139756270008ACE0 /* PopupViewTest-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 143F9FF8139756270008ACE0 /* PopupViewTest-Info.plist */; };
143FA002139756270008ACE0 /* PopupViewTestAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 143F9FFA139756270008ACE0 /* PopupViewTestAppDelegate.m */; };
143FA003139756270008ACE0 /* PopupViewTestViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 143F9FFC139756270008ACE0 /* PopupViewTestViewController.m */; };
14B7E42313BD9DB5007C8935 /* MainWindow-iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 14B7E42213BD9DB5007C8935 /* MainWindow-iPad.xib */; };
@@ -177,8 +176,11 @@
/* Begin PBXProject section */
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0420;
+ };
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "PopupViewTest" */;
- compatibilityVersion = "Xcode 3.1";
+ compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
@@ -201,7 +203,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 143FA001139756270008ACE0 /* PopupViewTest-Info.plist in Resources */,
14FDABA013977B3E008BF9D5 /* 2tchSmall.png in Resources */,
14FDABA113977B3E008BF9D5 /* Default.png in Resources */,
14FDABA213977B3E008BF9D5 /* Default@2x.png in Resources */,
@@ -272,7 +273,6 @@
GCC_PREPROCESSOR_DEFINITIONS = _DEBUG;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- PREBINDING = NO;
SDKROOT = iphoneos;
};
name = Debug;
@@ -286,7 +286,6 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
- PREBINDING = NO;
SDKROOT = iphoneos;
};
name = Release;
View
3  SNPopupView.h
@@ -30,6 +30,8 @@
#import <UIKit/UIKit.h>
+//#define _CONFIRM_REGION
+
#define SHADOW_OFFSET CGSizeMake(10, 10)
#define CONTENT_OFFSET CGSizeMake(10, 10)
#define POPUP_ROOT_SIZE CGSizeMake(20, 10)
@@ -110,6 +112,7 @@ typedef enum {
- (void)presentModalAtPoint:(CGPoint)p inView:(UIView*)inView;
- (void)presentModalAtPoint:(CGPoint)p inView:(UIView*)inView animated:(BOOL)animated;
+- (BOOL)shouldBeDismissedFor:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)dismiss;
- (void)dismiss:(BOOL)animtaed;
- (void)dismissModal;
View
19 SNPopupView.m
@@ -56,7 +56,8 @@ - (id)initWithFrame:(CGRect)frame {
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
DNSLogMethod
- [delegate dismissModal];
+ if ([delegate shouldBeDismissedFor:touches withEvent:event])
+ [delegate dismissModal];
}
@end
@@ -65,8 +66,7 @@ @implementation SNPopupView
@synthesize title, image, contentView, delegate;
-#pragma mark -
-#pragma mark Prepare
+#pragma mark - Prepare
- (void)setupGradientColors {
CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
@@ -441,6 +441,13 @@ - (void)popup {
[self.layer addAnimation:group forKey:@"hoge"];
}
+- (BOOL)shouldBeDismissedFor:(NSSet *)touches withEvent:(UIEvent *)event {
+ UITouch *touch = [touches anyObject];
+
+ CGPoint p = [touch locationInView:self];
+ return !CGRectContainsPoint(contentRect, p);
+}
+
- (void)dismissModal {
if ([peekView superview])
[delegate didDismissModal:self];
@@ -592,6 +599,12 @@ - (void)makeGrowingPathCircleCornerRect:(CGRect)rect radius:(float)radius {
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
DNSLogMethod
+
+ if ([self shouldBeDismissedFor:touches withEvent:event] && peekView != nil) {
+ [self dismissModal];
+ return;
+ }
+
if ([target respondsToSelector:action]) {
[target performSelector:action withObject:self];
}
Please sign in to comment.
Something went wrong with that request. Please try again.