diff --git a/Classes/ios/MMPopLabel.m b/Classes/ios/MMPopLabel.m index b45513e..930aec0 100644 --- a/Classes/ios/MMPopLabel.m +++ b/Classes/ios/MMPopLabel.m @@ -294,6 +294,9 @@ - (void)popAtBarButtonItem:(UIBarButtonItem *)barButtonItem - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { + if ([self.delegate respondsToSelector:@selector(shouldDismissPopLabelOnTouch:)] && ![self.delegate shouldDismissPopLabelOnTouch:self]) { + return; + } [self dismiss]; } diff --git a/Classes/ios/MMPopLabelDelegate.h b/Classes/ios/MMPopLabelDelegate.h index f53d624..5194631 100644 --- a/Classes/ios/MMPopLabelDelegate.h +++ b/Classes/ios/MMPopLabelDelegate.h @@ -8,5 +8,5 @@ @optional - (void)dismissedPopLabel:(MMPopLabel *)popLabel; - (void)didPressButtonForPopLabel:(MMPopLabel *)popLabel atIndex:(NSInteger)index; - +- (BOOL)shouldDismissPopLabelOnTouch:(MMPopLabel *)popLabel; @end diff --git a/Example/MMPopLabelDemo.xcodeproj/project.pbxproj b/Example/MMPopLabelDemo.xcodeproj/project.pbxproj index 6b227a6..83964ba 100644 --- a/Example/MMPopLabelDemo.xcodeproj/project.pbxproj +++ b/Example/MMPopLabelDemo.xcodeproj/project.pbxproj @@ -20,7 +20,8 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 411C275B680C4F7B88639510 /* Pods-MMPopLabelDemo.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MMPopLabelDemo.xcconfig"; path = "Pods/Pods-MMPopLabelDemo.xcconfig"; sourceTree = ""; }; + 12278B84F83D98EF1AB5B97D /* Pods-MMPopLabelDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MMPopLabelDemo.release.xcconfig"; path = "Pods/Target Support Files/Pods-MMPopLabelDemo/Pods-MMPopLabelDemo.release.xcconfig"; sourceTree = ""; }; + 41A71AA004C3C2B44A26839F /* Pods-MMPopLabelDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MMPopLabelDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-MMPopLabelDemo/Pods-MMPopLabelDemo.debug.xcconfig"; sourceTree = ""; }; C2B0691519349D01006A9EBF /* MMPopLabelDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MMPopLabelDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; C2B0691819349D01006A9EBF /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; C2B0691A19349D01006A9EBF /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; @@ -54,13 +55,22 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 974449C71EB331B549AC7B94 /* Pods */ = { + isa = PBXGroup; + children = ( + 41A71AA004C3C2B44A26839F /* Pods-MMPopLabelDemo.debug.xcconfig */, + 12278B84F83D98EF1AB5B97D /* Pods-MMPopLabelDemo.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; C2B0690C19349D01006A9EBF = { isa = PBXGroup; children = ( C2B0691E19349D01006A9EBF /* MMPopLabelDemo */, C2B0691719349D01006A9EBF /* Frameworks */, C2B0691619349D01006A9EBF /* Products */, - 411C275B680C4F7B88639510 /* Pods-MMPopLabelDemo.xcconfig */, + 974449C71EB331B549AC7B94 /* Pods */, ); sourceTree = ""; }; @@ -200,7 +210,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Pods-MMPopLabelDemo-resources.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-MMPopLabelDemo/Pods-MMPopLabelDemo-resources.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -310,7 +320,7 @@ }; C2B0694819349D01006A9EBF /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 411C275B680C4F7B88639510 /* Pods-MMPopLabelDemo.xcconfig */; + baseConfigurationReference = 41A71AA004C3C2B44A26839F /* Pods-MMPopLabelDemo.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; @@ -324,7 +334,7 @@ }; C2B0694919349D01006A9EBF /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 411C275B680C4F7B88639510 /* Pods-MMPopLabelDemo.xcconfig */; + baseConfigurationReference = 12278B84F83D98EF1AB5B97D /* Pods-MMPopLabelDemo.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; diff --git a/Example/MMPopLabelDemo/MMViewController.m b/Example/MMPopLabelDemo/MMViewController.m index 407a865..da03287 100644 --- a/Example/MMPopLabelDemo/MMViewController.m +++ b/Example/MMPopLabelDemo/MMViewController.m @@ -62,7 +62,6 @@ - (void)viewDidLoad [self.view addSubview:_label]; } - - (IBAction)showLabel:(id)sender { [_label popAtView:_showPopupButton]; @@ -117,5 +116,9 @@ - (void)didPressButtonForPopLabel:(MMPopLabel *)popLabel atIndex:(NSInteger)inde NSLog(@"pressed %li", (long)index); } +- (BOOL)shouldDismissPopLabelOnTouch:(MMPopLabel *)popLabel { + // optional delegate method, default is yes + return NO; +} @end diff --git a/README.md b/README.md index 5ef45e9..24831a6 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ To receive the label events, just set your view controller as it's delegate and ```objective-c - (void)dismissedPopLabel:(MMPopLabel *)popLabel; - (void)didPressButtonForPopLabel:(MMPopLabel *)popLabel atIndex:(NSInteger)index; +- (BOOL)shouldDismissPopLabelOnTouch:(MMPopLabel *)popLabel; ``` To disable animations, use of the following option when setting up your label: