Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 23    Views: 1115

LevensGardener
Aspiring developer
Profile
Posts: 220
Reg: Sep 30, 2012
Kendal
10,450
03/07/14 12:38 AM (10 years ago)

Disable swipe from left to go back?

I would like to disable 'swipe to go back' in an individual plugin. When a swipe from the left of the screen occurs, it seems BT_navController jumps in and leads the transition back to the previous screen via popViewControllerAnimated. This is not helpful behaviour when using the scratch feature plugin, as sooner or later a scratch/swipe from the left of the screen will send you back to the previous menu. I have looked and looked at code (it is certainly a good education), but I am in way over my depth here. Any suggestions?
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
03/07/14 02:38 AM (10 years ago)
I've got a fix for that stay tuned when i finish work
 
LevensGardener
Aspiring developer
Profile
Posts: 220
Reg: Sep 30, 2012
Kendal
10,450
like
03/07/14 02:52 AM (10 years ago)
Kittsy, I knew I only had to catch your eye with an interesting problem, and it would be fixed.... Thank you! ps. if it helps you focus in on the problem- When returning to the scratch view screen following an untimely swipe out, the offending behaviour doesn't repeat when coming out of your carousel menu (or Chris1's Tumblr menu). But, strangely enough, the swipe back recurs every time when coming back out to it from the simple menu.
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
03/07/14 08:17 AM (10 years ago)
Right here we go The first is for individual plugins insert this in the viewWillAppear: method if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = NO; } this is the important line self.navigationController.interactivePopGestureRecognizer.enabled = NO; the if statement checks whether the nav controller has can perform that method. below iOS 7 can't so it stops the app from crashing if you want the swipe feature to work on other screens we need to re enable the method add this outside any other curly braces. -(void)viewWillDisappear:(BOOL)animated{ if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = YES; } } This si exactly the same except it says yes if you want the whole app to get rid of this functionality go to BT_viewController.m in the viewDidLoad methods add if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = NO; } it will never bother you again
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
03/07/14 11:15 AM (10 years ago)
There ya go Chris, with an aptly titled post, rescue comes galloping in :-)
 
LevensGardener
Aspiring developer
Profile
Posts: 220
Reg: Sep 30, 2012
Kendal
10,450
like
03/07/14 11:23 AM (10 years ago)
Thanks for this Kittsy- I would have never got there. And thanks Niraj for sticking with me on this one. I have been playing with this for a while now, and interestingly Kittsy's solution throws up more questions and observations. I'll look some more , then I'll be back!
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
03/07/14 11:25 AM (10 years ago)
What questions has it thrown up lol
 
LevensGardener
Aspiring developer
Profile
Posts: 220
Reg: Sep 30, 2012
Kendal
10,450
like
03/07/14 11:48 AM (10 years ago)
Ah well, it seems the Mr David's scratch view plugin has not been adapted to fit in perfectly with the BuzzTouch way? No viewWillAppear. I am experimenting poking your code in where it will not throw problems - viewDidLoad is where I have put it at present. Looking at my test app further though, it seems that swipe from left is active everywhere! All plugins! At least for the first swipe from left. That includes your carousel menu screen Kittsy. I suspect this came in with iOS7. Most interestingly, once you have gone back to a previous screen by a swipe from left, it seems to knock out this behaviour in all further screens and plugins. Strange... I'll experiment further. Thanks again, Chris
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
03/07/14 11:54 AM (10 years ago)
create it -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = NO; } }
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
03/07/14 11:55 AM (10 years ago)
You are getting close! :-)
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
03/07/14 02:29 PM (10 years ago)
I've done a nice tidy tutorial on http://kittsy.co.uk/disable-ios-7-swipe-back-feature/ explains all the steps
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
03/07/14 03:08 PM (10 years ago)
Very very very nice tutorial, Andy! ----- An aside, take a look at your tutorial with an iPhone using Safari. Notice that the Reader function does not activate. I use the Reader to send the entire post via email to my BuzzTouch folder for future reference. Is this a non-standard blog post? Perhaps that is why the Reader function of Safari is not recognizing it? ----- Thank you for the nice tutorial. -- Niraj
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
03/07/14 03:12 PM (10 years ago)
It's probably because of the code snippets, so it can be copied and pasted easily
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
03/07/14 03:16 PM (10 years ago)
looking at a few other code blogs reader doesn't seem to like syntax boxes, but I feel for a coding website staying how it is, is more beneficial, your nit going to copy out reams of code from your iPhone are you
 
LevensGardener
Aspiring developer
Profile
Posts: 220
Reg: Sep 30, 2012
Kendal
10,450
like
03/07/14 03:20 PM (10 years ago)
Huge thanks Kittsy. Will study harder and reply properly when less pop in the bloodstream... Chris
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
03/07/14 06:20 PM (10 years ago)
Kitsy -- I do indeed copy reams of code and articles from blog articles and from BT postings. I shall find one example that Reader can do just fine with code blocks. http://ios-blog.co.uk/tutorials/objective-c-strings-a-guide-for-beginners/ My BT Folder is chock-full of tips! Most were mined via the iPhone or iPad. Can you make sure that a normal no-code article on your Blog can use the Reader tool?
 
LevensGardener
Aspiring developer
Profile
Posts: 220
Reg: Sep 30, 2012
Kendal
10,450
like
03/08/14 08:39 AM (10 years ago)
Kittsy, as always you come up with the answers! Thank you so much. The tutorial you put together helps immensely and also helps beginners like me see how it all fits in. That is great. Your solutions work perfectly of course. I am however amazed that iOS 7 has been out for six months and no one has noticed this glitch before. It seems all screens have a swipe left built in now. There is something very strange about the way Buzztouch at its core handles it though. After the first swipe left, whenever and wherever that occurs in an app, it seems the gesture is never recognised again until the app is reloaded/refreshed. That is what happens in my test apps anyway. The exception is coming in/out of a simple menu. There, that swipe from left to return can be repeated. In this case, the gesture recogniser does not get cancelled after the first swipe. Its all very strange... Thanks again for lighting our way through the darkness! Chris
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
03/08/14 08:50 AM (10 years ago)
Chris -- can you detail the steps and plugins to identify the problem? Try to explain two different paths that use different plugins. Perhaps we can squash that bug.
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
03/08/14 09:07 AM (10 years ago)
I see the behavior now in my own app. It happens when transitioning from the XIB Button Menu to the Menu Advanced plugin and then into my custom Cubbyholes plugin. Another path is from the XIB Button Menu to the Blank Screen plugin (or Tumblr Menu or Carousel or RSS). I too had noticed it, yet had shrugged it off as me being a clumsy swiping person. Interesting bug! Now that Kittsy has given us knowledge, we can start looking in all the right places. You first, Chris! Finders, keepers :-)
 
LevensGardener
Aspiring developer
Profile
Posts: 220
Reg: Sep 30, 2012
Kendal
10,450
like
03/08/14 09:10 AM (10 years ago)
I'll make a couple more test apps to check I am right in what I am talking about (or the glitch is just in what I have done!). I have been away from Buzztouch app making for a while, and maybe the new Xcode and iOS7 and Buzztouch 3.0 is confusing me. It is just that in one of the test apps I have done, the ability to left swipe back is available on any screen (tumblr menu, carousel menu, voucher access, scratch feature). But once it has been activated on one screen, just once, it is not available anywhere again within that app. Only a reset/refresh reactivates the gesture recogniser. In another test app, the swipe left feature remains active throughout, however many times you use it. As I am testing them now, it might be to do with the screen transitions- 'normal' transitions- the new screen sliding across, then being swiped away allow the gesture recogniser to continue working. In the app where the gesture recogniser is disabled after its first use, I have set the transitions to a fade. I might be getting to the bottom of it...
 
LevensGardener
Aspiring developer
Profile
Posts: 220
Reg: Sep 30, 2012
Kendal
10,450
like
03/08/14 09:12 AM (10 years ago)
It is interesting, and I almost shrugged it off, because it is tricky to get it to repeat enough to be certain what is happening. It also makes for a great learning process! Thanks for playing along with me here Niraj...
 
LevensGardener
Aspiring developer
Profile
Posts: 220
Reg: Sep 30, 2012
Kendal
10,450
like
03/09/14 01:40 AM (10 years ago)
OK. I think I have it! (more questions, not solutions!) Or at least I think I am 95% of the way to pinpointing the problem behaviour, and it is doing my head in so much, it is time to share... The latest iOS7, BuzzTouch and Xcode builds have this gesture recogniser system built in- Apps are always 'listening' for a suitable swipe from the left to pop the current screen and go back one. All good stuff and Kittsy has just shown us the way to disable/enable this feature- fantastic work. Thank you Mr Kitts. This swipe to go back feature actually works just fine with the default transition, which is after all new screens sliding in and out from the side. But, here is where it all goes wrong... Change the transitions to anything else and the problems start. With screens using fade, flip, curl, etc, Swipe to go back works once perfectly, before the behaviour is disabled for that screen and you have to use the top nav bar to go back. It continues to be disabled for that screen until you refresh/reload or restart the app. Strangely, once used for one screen this swipe back behaviour can then be disabled for all screens (including different plugins) that have anything other than the default transition. Stranger still, returning to the simple menu and using a standard transition from there with swipe back seems to reset everything to work normally again. At least until that first swipe back through a fade/flip/curl etc disables the behaviour. (other strange things can occur around this issue, but lets keep it simple for now!) It seems to me there is some conflict deep down in the code between the handling of these transitions and the new iOS7 swipe to go back feature. I would be interested to know if when you look, you find the same. And of course if it is a problem that can be fixed. Thank you
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
03/09/14 07:12 AM (10 years ago)
I hear ya -- going to be a week before I can peek at it. Hit up Kittsy in the meanwhile? Have you logged it in the http://buzz-tools.com database against the Advanced Menu plugin? That is the one I have the problem with.
 
LevensGardener
Aspiring developer
Profile
Posts: 220
Reg: Sep 30, 2012
Kendal
10,450
like
03/09/14 07:15 AM (10 years ago)
I'm certainly hoping to catch Kittsy's eye here again. Just wondering though if it is just me? and my set-up, or is this behaviour replicated...
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.