您想使用URL
。
mainDocumentURL
將在加載頁面的子部分(如圖像,腳本等)時用於告知系統加載這些子部分時可以安全使用哪些Cookie。無論如何,這並不是你想要展示的內容,並且記錄在當前版本的框架中未被使用。
/*!
@method mainDocumentURL
@abstract The main document URL associated with this load.
@discussion This URL is used for the cookie "same domain as main
document" policy. There may also be other future uses.
See setMainDocumentURL:
NOTE: In the current implementation, this value is unused by the
framework. A fully functional version of this method will be available
in the future.
@result The main document URL.
*/
該文檔在哪裏說它是未使用的?它看起來像我運行的測試中沒有設置該URL,並且在某些情況下在webView中設置了mainDocumentURL:shouldStartLoadWithRequest:navigationType:delegate方法。 – Austin
我不清楚NSURLRequest如何加載任何東西,如果它沒有URL加載,但我不是這個領域的專家。 –
我會建議使用mainDocumentURL而不是URL。事實上,URL可以引用UIWebView當前顯示的網站的子部分。 – Joss