Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 3    Views: 124

immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
12/22/16 01:21 AM (7 years ago)

iOs app - No links clickable in customHTML plugin page

Im currently working on the iOS version of an app I've just released on android. Using iOs 8.0 build target App loads fine, Home page 'customHTML' page loads fine. Click on any buttons and nothing happens. No errors or any action in debugger. User interactions is enabled and I tested they are working by adding a dropdown menu and that worked. Ive redownloaded source code and tried other html pages that I've used in the past. source code was downloaded 7 December 2016 my last app that had no issues was downloaded 2 September 2016 Anyone sharing this issue or any ideas? Thanks Kristan Immacul8 Apps
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
12/22/16 02:00 AM (7 years ago)
Ok after looking around id say its due to the fact UIWebView has changed to WKWebView from iOs 8 and up. CustomHTML plugin is built around UIWebView so will need to be migrated to WKWebView
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
12/26/16 05:15 PM (7 years ago)
So after successfully editing the required code to change UIWebView to WKWebview I found that there is a simpler way to fix my problem. In BT_screen_customHTML plugin under //view will appear -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [BT_debugger showIt:self theMessage:@"viewWillAppear"]; Ive added webView.delegate = self; and now all my links are clickable again. Hope this helps anyone else who faces the same problem when building apps that target ios8 or higher Thank You Kristan Halls Immacul8 Apps
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
12/26/16 05:46 PM (7 years ago)
If you would like to take advantage of WKWebview here are the required changes. First of all in BT_screen_customHTML.h add #import <WebKit/WebKit.h> change @interface BT_screen_customHTML : BT_viewController <BT_downloadFileDelegate, UIWebViewDelegate, UIActionSheetDelegate>{ UIWebView *webView; UIToolbar *browserToolBar; NSString *externalURL; NSString *localFileName; NSString *saveAsFileName; NSString *dataURL; BT_downloader *downloader; int didInit; int downloadInProgress; } to @interface BT_screen_customHTML : BT_viewController <BT_downloadFileDelegate, WKNavigationDelegate, WKUIDelegate, UIActionSheetDelegate>{ WKWebView *webView; UIToolbar *browserToolBar; NSString *externalURL; NSString *localFileName; NSString *saveAsFileName; NSString *dataURL; BT_downloader *downloader; int didInit; int downloadInProgress; } change @property (nonatomic, retain) UIWebView *webView; to @property (nonatomic, retain) WKWebView *webView; and change -(BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType; to -(BOOL)webView:(WKWebView*)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler; now in BT_screen_customHTML.h add #import <WebKit/WebKit.h> then every instance of UIWebView needs to be changed to WKWebView, you can do this by doing and find/replace. then underneath //webView delegate methods //when a link inside the html document is clicked change -(BOOL)webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType{ [BT_debugger showIt:self theMessage:@"shouldStartLoadWithRequest"]; NSURL *url = request.URL; NSString *urlString = [url absoluteString]; NSString *urlScheme = [url scheme]; [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"url to load: %@", urlString]]; [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"url scheme: %@", urlScheme]]; //bail if this is an "about" request, very common in javascript ads, and banners, and other stuff.. to -(BOOL)webView:(WKWebView*)theWebView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy)) decisionHandler{ [BT_debugger showIt:self theMessage:@"shouldStartLoadWithRequest"]; webView.navigationDelegate = self; NSURL *url = navigationAction.request.URL; NSString *urlString = [url absoluteString]; NSString *urlScheme = [url scheme]; NSURLRequest *nsrequest=[NSURLRequest requestWithURL:url]; decisionHandler(WKNavigationActionPolicyAllow); [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"url to load: %@", urlString]]; [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"url scheme: %@", urlScheme]]; //bail if this is an "about" request, very common in javascript ads, and banners, and other stuff.. pretty sure that covers it. Kristan Halls Immacul8 Apps
 

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.