2015-10-07 84 views
2

在我的基于科尔多瓦的iOS应用程序,当我试图从主页导航到下一个屏幕时,它仍然在iOS 9的主页,其中作为导航工作正常与iOS 8.4及以下。设备位置路径错误导航的屏幕在iOS 9

这里是iOS的8.4(工作正常)

文件的路径:///var/mobile/Containers/Bundle/Application/EABC-4728-97BF-466B/MyApp.app/www/ 索引telugu.html#publicinterface

这里是在IOS 9.0的路径是从假定路径

文件不同:/// VAR /移动/容器/捆绑/应用/ 47C F-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) 
      }); 
     } 
     }); 

回答

4

iOS的9.0的UIWebView(由科尔多瓦/ PhoneGap的使用)的一个错误/ “功能” 是window.location.hash该设置是异步的 - 见this bug report的详细信息。需要注意的是Safari浏览器在iOS 8+使用WKWebView不是UIWebView的,所以这个问题不是明显在Safari浏览器在iOS 9.0

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 
} 

作为一种变通方法,您可以尝试使用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); 
+0

谢谢......这对我来说真的是一种魔力......它对您的解决方案非常有用。 – Sujania