Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.

add ability to not dismiss pop label on touch #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions Classes/ios/MMPopLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down
2 changes: 1 addition & 1 deletion Classes/ios/MMPopLabelDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
@optional
- (void)dismissedPopLabel:(MMPopLabel *)popLabel;
- (void)didPressButtonForPopLabel:(MMPopLabel *)popLabel atIndex:(NSInteger)index;

- (BOOL)shouldDismissPopLabelOnTouch:(MMPopLabel *)popLabel;
@end
20 changes: 15 additions & 5 deletions Example/MMPopLabelDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<group>"; };
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 = "<group>"; };
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 = "<group>"; };
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; };
Expand Down Expand Up @@ -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 = "<group>";
};
C2B0690C19349D01006A9EBF = {
isa = PBXGroup;
children = (
C2B0691E19349D01006A9EBF /* MMPopLabelDemo */,
C2B0691719349D01006A9EBF /* Frameworks */,
C2B0691619349D01006A9EBF /* Products */,
411C275B680C4F7B88639510 /* Pods-MMPopLabelDemo.xcconfig */,
974449C71EB331B549AC7B94 /* Pods */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion Example/MMPopLabelDemo/MMViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ - (void)viewDidLoad
[self.view addSubview:_label];
}


- (IBAction)showLabel:(id)sender
{
[_label popAtView:_showPopupButton];
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down