Skip to content

Commit

Permalink
Merge pull request #8 from Tawa/TapMask
Browse files Browse the repository at this point in the history
Tap mask
  • Loading branch information
Tawa authored Dec 3, 2017
2 parents f66583e + b422ae8 commit 781e2cd
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ The other optional methods will help you easily make an interactive tutorial:
*/
-(BOOL)tutorialWaitAfterAction:(NSInteger)index;

/**
Implementing this gives you the ability to force the user to tap on highlighted views instead of anywhere.
If there are no views highlighted in a certain tutorial step, this will be ignored, and the user will be able to tap anywhere.
*/
-(BOOL)tutorialAcceptTapsOnHighlightsOnly:(NSInteger)index;

/**
Methods used for building Tutorial UI.
*/
Expand Down
8 changes: 8 additions & 0 deletions Sample/TNTutorialManagerSample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
382AC6BE1FD4405D00BDE12D /* TNTutorialManager.podspec in Resources */ = {isa = PBXBuildFile; fileRef = 382AC6BD1FD4405C00BDE12D /* TNTutorialManager.podspec */; };
382AC6C01FD4427900BDE12D /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 382AC6BF1FD4427900BDE12D /* README.md */; };
38AD3A221F09E4CF003C4498 /* DetailsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 38AD3A211F09E4CF003C4498 /* DetailsViewController.m */; };
38E9F8CB1F0059A70008FB02 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 38E9F8CA1F0059A70008FB02 /* main.m */; };
38E9F8CE1F0059A70008FB02 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 38E9F8CD1F0059A70008FB02 /* AppDelegate.m */; };
Expand All @@ -19,6 +21,8 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
382AC6BD1FD4405C00BDE12D /* TNTutorialManager.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = TNTutorialManager.podspec; path = ../../TNTutorialManager.podspec; sourceTree = "<group>"; };
382AC6BF1FD4427900BDE12D /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../../README.md; sourceTree = "<group>"; };
38AD3A201F09E4CF003C4498 /* DetailsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetailsViewController.h; sourceTree = "<group>"; };
38AD3A211F09E4CF003C4498 /* DetailsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DetailsViewController.m; sourceTree = "<group>"; };
38E9F8C61F0059A70008FB02 /* TNTutorialManagerSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TNTutorialManagerSample.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -67,6 +71,8 @@
38E9F8C81F0059A70008FB02 /* TNTutorialManagerSample */ = {
isa = PBXGroup;
children = (
382AC6BF1FD4427900BDE12D /* README.md */,
382AC6BD1FD4405C00BDE12D /* TNTutorialManager.podspec */,
38E9F8E61F0059DA0008FB02 /* TNTutorialManager */,
38E9F8CC1F0059A70008FB02 /* AppDelegate.h */,
38E9F8CD1F0059A70008FB02 /* AppDelegate.m */,
Expand Down Expand Up @@ -164,6 +170,8 @@
files = (
38E9F8DC1F0059A70008FB02 /* LaunchScreen.storyboard in Resources */,
38E9F8D91F0059A70008FB02 /* Assets.xcassets in Resources */,
382AC6C01FD4427900BDE12D /* README.md in Resources */,
382AC6BE1FD4405D00BDE12D /* TNTutorialManager.podspec in Resources */,
38E9F8D71F0059A70008FB02 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
5 changes: 5 additions & 0 deletions Sample/TNTutorialManagerSample/FirstViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ -(void)viewDidAppear:(BOOL)animated
return nil;
}

-(BOOL)tutorialAcceptTapsOnHighlightsOnly:(NSInteger)index
{
return YES;
}

-(NSArray<NSString *> *)tutorialTexts:(NSInteger)index
{
if (index == 0) {
Expand Down
4 changes: 2 additions & 2 deletions TNTutorialManager.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TNTutorialManager'
s.version = '1.2'
s.version = '1.3'
s.summary = 'Tutorial Handler that helps you implement interactive tutorials inside your iOS Apps.'

s.description = "TNTutorialManager is a manager that helps you implement interactive tutorials inside your iOS Apps."
Expand All @@ -11,7 +11,7 @@ Pod::Spec.new do |s|
s.source = { :git => 'https://github.com/Tawa/TNTutorialManager', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/TawaNicolas'

s.ios.deployment_target = '8.0'
s.ios.deployment_target = '10.0'

s.subspec 'TNTutorialManager' do |ss|
ss.source_files = 'TNTutorialManager'
Expand Down
6 changes: 6 additions & 0 deletions TNTutorialManager/TNTutorialManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ typedef NS_ENUM(NSInteger, TNTutorialTextPosition) {
*/
-(BOOL)tutorialWaitAfterAction:(NSInteger)index;

/**
Implementing this gives you the ability to force the user to tap on highlighted views instead of anywhere.
If there are no views highlighted in a certain tutorial step, this will be ignored, and the user will be able to tap anywhere.
*/
-(BOOL)tutorialAcceptTapsOnHighlightsOnly:(NSInteger)index;

/**
Methods used for building Tutorial UI.
*/
Expand Down
23 changes: 23 additions & 0 deletions TNTutorialManager/TNTutorialManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,29 @@ -(void)updateHighlights

-(void)updateTutorial:(UITapGestureRecognizer *)sender
{
if (sender && [self.delegate respondsToSelector:@selector(tutorialAcceptTapsOnHighlightsOnly:)]) {
NSArray <UIView *> *viewsToHighlight;
if ([self.delegate respondsToSelector:@selector(tutorialViewsToHighlight:)]) {
viewsToHighlight = [self.delegate tutorialViewsToHighlight:[self currentIndex]];
CGPoint tapLocation = [sender locationInView:sender.view];
BOOL shouldAcceptTaps = NO;
if (viewsToHighlight) {
for (UIView *view in viewsToHighlight) {
CGRect frame = [[self tutorialContainer] convertRect:[view frame] fromView:view.superview];
if (CGRectContainsPoint(frame, tapLocation)) {
shouldAcceptTaps = YES;
break;
}
}
} else {
shouldAcceptTaps = YES;
}
if (!shouldAcceptTaps) {
return;
}
}
}

BOOL update = YES;
BOOL wrapUp = NO;
if ([self.delegate respondsToSelector:@selector(tutorialWaitAfterAction:)]) {
Expand Down

0 comments on commit 781e2cd

Please sign in to comment.