I am developing an iOS application with Objective-C
, I wanted to move from UIWebView
to WKWebView
.
However, an error occurred in the part which I wrote in this way before.
WKWebView * webview = [[WKWebView alloc] initWithFrame: CGRectZero];
...
if (! webview.request) {
...
}
The errors are as follows.
Property 'request' not found on object of type 'WKWebView *'
If you can understand, please tell me how to fix it.
Thank you.
Error message is clear WKWebView
don't have request
property you should use load(_ request: URLRequest) -> WKNavigation?
method and check for url property instead
as is defined in WKWebView
class
/*! @abstract The active URL.
@discussion This is the URL that should be reflected in the user
interface.
@link WKWebView @/link is key-value observing (KVO) compliant for this
property.
*/
open var url: URL? { get }
your code should be
WKWebView * webview = [[WKWebView alloc] initWithFrame: CGRectZero];
...
if (!webview.url) {
...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.