Cocoa 带有 UIApplication 和 UIWebView 的 Touch 库

Cocoa Touch library with UIApplication and UIWebView

WebView google 网站在这种情况下未加载

当我们尝试使用时,它被加载了...

谁能指导我如何在 cocoa 触摸库项目

中编写第一个代码

使用此代码将 UIWebView 添加到 App 键 Window,你的问题是可能你使用代码的地方 self.view 是 nil,我想

UIApplication * app = [UIApplication sharedApplication];
UIWebView* web = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, app.keyWindow.frame.size.width, app.keyWindow.frame.size.height)];
web.layer.borderWidth = 1;
web.layer.borderColor = [[UIColor redColor] CGColor];
NSURLRequest * req = [[NSURLRequest alloc]initWithURL:[NSURL URLWithString:@"https://www.w3schools.com"]];
[web loadRequest:req];
[app.keyWindow addSubview:web];

希望这对我有帮助,因为我应该工作

使用委托实现webview从静态库到应用

    [[UIApplication sharedApplication] setStatusBarHidden:YES];
    // UIApplication * app = [UIApplication sharedApplication];
    UIWebView *web=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];

    web.layer.borderWidth = 1;
    web.layer.borderColor = [[UIColor redColor] CGColor];
   // NSURLRequest * req = [[NSURLRequest alloc]initWithURL:[NSURL URLWithString:@"https://www.yahoo.com"]];

  [web loadRequest:req];
 [self.adView addSubview:web];

专注于adView ...这里你会卡住...

试试这个代码...

[[UIApplication sharedApplication] setStatusBarHidden:YES];
 UIWebView *web=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];

web.layer.borderWidth = 1;
web.layer.borderColor = [[UIColor redColor] CGColor];

[网络loadRequest:req]; [self.adView addSubview:web];