2016-09-01 14 views
1

ドロップダウンを持つUIWebViewにWebサイトのページを表示しています。ユーザーはドロップダウンから値を選択できますが、アプリケーションを閉じてから再び開くと、このドロップダウンではユーザーが選択できなくなります。IOS 9のUIWebViewでドロップダウンを選択できません

奇妙なことに、そのドロップドウオンでjavascript onclickのアラートボックスを表示すると、アラートボックスのokボタン(ドロップダウンがクリック可能になることを意味する)をタップしても問題なく動作します。

答えて

1

私は同じ問題を持っていた私は、次のように置くドロップダウンはあなたのコントローラがのUIWebViewを持って

var appname = 'yourappName'; 
     var actionName = 'displayAlert'; 
     var url = appname + '://' + actionName; 
     document.location.href = url; 

存在しているdocument.readyはJavaScriptライン以下のウェブサイトのプットでは、それ に対処するための回避策を見出したので、コード

- (BOOL)webView:(UIWebView *)webView 
shouldStartLoadWithRequest:(NSURLRequest *)request 
navigationType:(UIWebViewNavigationType)navigationType { 

    // these need to match the values defined in your JavaScript 
    NSString *myAppScheme = @"wfsapp"; 
    NSString *myActionType = @"displayAlert"; 

    // ignore legit webview requests so they load normally 
    if (![request.URL.scheme isEqualToString:myAppScheme]) { 
     return YES; 
    } 

    // get the action from the path 
    NSString *actionType = request.URL.host; 


    // look at the actionType and do whatever you want here 
    if ([actionType isEqualToString:myActionType]) { 
    /* UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Loading" 
                 message:@"Initialising Search Filters..." 
                 delegate:self 
               cancelButtonTitle:NULL 
               otherButtonTitles:nil];*/ 



     //[alert show]; 
    /* UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" 
                     message:NULL 
                   preferredStyle:UIAlertControllerStyleActionSheet]; 
     alertController.view.hidden = YES; 

     alertController.modalPresentationStyle = UIModalPresentationCurrentContext; 
     alertController.view.backgroundColor = [UIColor clearColor];*/ 
     UIViewController *alertController = [UIViewController alloc]; 
     alertController.view.hidden = YES; 
     alertController.view.backgroundColor = [UIColor clearColor]; 

     self.view.backgroundColor = [UIColor clearColor]; 
     self.modalPresentationStyle = UIModalPresentationCurrentContext; 

     [self presentViewController:alertController animated:NO completion:^ { 




     }]; 
     [alertController dismissViewControllerAnimated:NO completion:nil]; 

    } 

ページの読み込みとjavascriptのラインは、コードのdoesnt上で実行されているすべてのViewControllerをdislpayが、それは再び

を仕事にdropddownトリガー
+0

ありがとうございました。魅力的に働きました! –

関連する問題