Browse Source

iOS: disable WebView navigation once loaded; tweak alert msg

Pal Lockheart 6 years ago
parent
commit
2cb1d0f067

+ 6 - 3
ios/SDLPal/SDLPal/SPWebViewController.m

@@ -9,7 +9,9 @@
 #import "SPWebViewController.h"
 #define UIKitLocalizedString(key) [[NSBundle bundleWithIdentifier:@"com.apple.UIKit"] localizedStringForKey:key value:@"" table:nil]
 
-@interface SPWebViewController ()<UIWebViewDelegate>
+@interface SPWebViewController ()<UIWebViewDelegate> {
+    BOOL finished;
+}
 
 @property (strong, nonatomic) IBOutlet UIWebView *webView;
 
@@ -30,15 +32,16 @@
 }
 
 - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
-    if( [request.URL.path containsString:self.signature] ) {
+    if( [request.URL.path hasSuffix:self.signature] ) {
         [self.navigationController popViewControllerAnimated:YES];
         [self.delegate capturedURL:request.URL];
         return NO;
     }
-    return YES;
+    return !finished;
 }
 
 - (void)webViewDidFinishLoad:(UIWebView *)webView {
+    finished = YES;
     [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
     [self setTitle:[self.webView stringByEvaluatingJavaScriptFromString:@"document.title"]];
 }

+ 2 - 2
ios/SDLPal/SDLPal/SettingsTableViewController.m

@@ -231,7 +231,7 @@ typedef void(^SelectedBlock)(NSString *selected);
                                       [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
                                       if( error ) {
                                           [alert dismissViewControllerAnimated:YES completion:nil];
-                                          UIAlertController  *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Error",nil)
+                                          UIAlertController  *alert = [UIAlertController alertControllerWithTitle:nil
                                                                                                           message:[error localizedDescription]
                                                                                                    preferredStyle:UIAlertControllerStyleAlert];
                                           UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:UIKitLocalizedString(@"OK") style:UIAlertActionStyleDefault handler:nil];
@@ -250,7 +250,7 @@ typedef void(^SelectedBlock)(NSString *selected);
                                                       completionHandler:^(NSString * _Nonnull path, BOOL succeeded, NSError * _Nonnull error) {
                                                           [alert dismissViewControllerAnimated:YES completion:nil];
                                                           if( error ) {
-                                                              UIAlertController  *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Error",nil)
+                                                              UIAlertController  *alert = [UIAlertController alertControllerWithTitle:nil
                                                                                                                               message:[error localizedDescription]
                                                                                                                        preferredStyle:UIAlertControllerStyleAlert];
                                                               UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:UIKitLocalizedString(@"OK") style:UIAlertActionStyleDefault handler:nil];