Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 6    Views: 162

chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
09/08/14 06:24 PM (9 years ago)

Tip of the day: Going back in webview history on iOS

Here's a useful tip for people using the Custom URL plugin. Have you ever been frustrated that the back button on the navbar doesn't go back in navigation, but to the previous screen altogether? Here's a quick way to solve it: Step 1) In the -(void)viewWillAppear method, add this code: UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(navLeftTap)]; self.navigationItem.leftBarButtonItem = backButton; Step 2) Outside the curly braces (right after the viewWillAppear method finishes is fine), add this code: -(void)navLeftTap { [BT_debugger showIt:self message:@"navLeftTap"]; if([self.webView canGoBack]){ [self.webView goBack]; } else [super navLeftTap]; }
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
like
09/08/14 10:34 PM (9 years ago)
Thanks, Chris! This is very handy.
 
MadRod
Aspiring developer
Profile
Posts: 1853
Reg: Apr 12, 2012
Lisbon
27,930
like
09/09/14 01:59 AM (9 years ago)
Cool.
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
09/09/14 04:24 AM (9 years ago)
Thanks Chris, works a treat - I tried it on the custom URL plugin.
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
09/09/14 08:12 AM (9 years ago)
Thanks, great solution
 
Crown Solutions
Aspiring developer
Profile
Posts: 463
Reg: Nov 11, 2011
MN
13,480
like
09/10/14 06:24 AM (9 years ago)
Thanks Chris, this will be a big help in an ad hoc app I have
 
LeonG
Apple Fan
Profile
Posts: 694
Reg: Nov 08, 2011
Hamburg
17,740
like
11/28/14 04:16 PM (9 years ago)
wow, kinda missed this one. 10000 thumbs up!
 

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.