簡體   English   中英

分配給&#39;id <UIWebViewDelegate> _Nullable”來自不兼容類型“ WebView * const __strong”

[英]Assigning to 'id<UIWebViewDelegate> _Nullable' from incompatible type 'WebView *const __strong'

當我添加webView.delegate = self; 通過以下代碼訪問網絡視圖

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height-64)];
    NSString *htmlFile = [[NSUserDefaults standardUserDefaults] objectForKey:USER_CODE];
     NSLog(@"Value retured : %@",htmlFile);
    NSURL *url = [NSURL URLWithString:htmlFile];
    webView.delegate = self;
    [webView loadRequest:[NSURLRequest requestWithURL:url]];
    [self.view addSubview:webView];
}

我收到以下錯誤。

/Applications/MAMP/htdocs/iOS/SchoolApp/test/WebView/WebView.m:25:22: Assigning to 'id<UIWebViewDelegate> _Nullable' from incompatible type 'WebView *const __strong'

您的View控制器未實現UIWebViewDelegate協議。請勿在類的接口聲明中使用它

@interface YourViewControllerName : UIViewController <UIWebViewDelegate>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM