在iOS 9中导航屏幕的设备位置路径错误

sou*_*mya 2 html ios cordova ios9

在我基于Cordova的iOS应用程序中,当我尝试从主页导航到下一个屏幕时,它仍然保留在iOS 9的主页中,其中导航在iOS 8.4及更低版本中正常工作.

这是iOS 8.4中的路径(工作正常)

文件:///var/mobile/Containers/Bundle/Application/EABC-4728-97BF-466B/MyApp.app/www/ 指数telugu.html#publicinterface

这是iOS 9.0中与假定路径不同的路径

文件:///var/mobile/Containers/Bundle/Application/47CF-A77E-97ACED384A/MyApp.app/www/ 指数telugu.html#主

如果有人遇到类似的问题请建议我解决这个问题的方法

这是我的代码:

    $('#publicinterface_main_id').click(function()
      {

         if (!checkConnection())
        {           
            navigator.notification.alert('Please Check Your Internet Connection');
        }
        else if (!navigator.geolocation) 
        {
            navigator.notification.alert('Please switch on location settings on your mobile');
        }
        else 
        {

            window.location.href = "index-telugu.html#"+$(this).attr('reloadIndex');

            console.log("Path for navigation: : " + window.location.href );

            location.reload();                
            navigator.geolocation.getCurrentPosition(function (p) 
            {
                getAddress(p.coords.latitude,p.coords.longitude);
                $('#pub_HgeoLocation').val(p.coords.latitude+","+p.coords.longitude);
            });

         var places = new google.maps.places.Autocomplete(document.getElementById('pub_geoLocation'));
         google.maps.event.addListener(places, 'place_changed', function () 
            {
                var place = places.getPlace();
                var address = place.formatted_address;
                var longitude = place.geometry.location.lng();
                var latitude = place.geometry.location.lat();
                $('#pub_HgeoLocation').val(latitude+","+longitude)
            });
        }
      });
Run Code Online (Sandbox Code Playgroud)

Dav*_*den 5

iOS 9.0 UIWebView(由Cordova/Phonegap使用)的错误/"功能" window.location.hash是异步设置- 有关详细信息,请参阅此错误报告.请注意,iOS 8+上的Safari使用WKWebView而非UIWebView,因此在iOS 9.0的Safari浏览器中此问题并不明显

console.log(window.location.hash); // -> "#bar"
window.location.hash = '#foo';

console.log(window.location.hash); 
// -> "#bar" // iOS 9.0 UIWevView
// -> "#foo" // iOS 9.0 WKWebView (Safari) and all other known browsers except

// in all other known browsers at this point window.location.hash will read '#foo'. In iOS9 UIWebView it won't.
if(window.location.hash !== '#foo') {
  // bang: iOS 9 webview
} else {
  // ok: any other browser
}
Run Code Online (Sandbox Code Playgroud)

作为一种变通方法,您可以尝试window.setTimeout在设置值window.location.hash异步后进行操作,允许在使用之前应用该值.因此,使用上面的代码,尝试以下方法:

window.location.href = "index-telugu.html#"+$(this).attr('reloadIndex');

window.setTimeout(function(){
    console.log("Path for navigation: : " + window.location.href );
    location.reload();    
},0);
Run Code Online (Sandbox Code Playgroud)