Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Objective-C UIWebView初始化错误_Ios_Objective C_Iphone - Fatal编程技术网

Ios Objective-C UIWebView初始化错误

Ios Objective-C UIWebView初始化错误,ios,objective-c,iphone,Ios,Objective C,Iphone,当我试图执行这段代码时,我的应用程序正在崩溃。我不熟悉objective-C,所以我不确定问题出在哪里 - (void)loadWebView:(NSURL *)url { UIWebView *nWeb = _webView; if(nWeb == nil) { nWeb =[[UIWebView alloc]init]; } [[self webView] loadRequest:[NSURLRequest requestW

当我试图执行这段代码时,我的应用程序正在崩溃。我不熟悉objective-C,所以我不确定问题出在哪里

   - (void)loadWebView:(NSURL *)url {
      UIWebView *nWeb = _webView;
      if(nWeb == nil) {
       nWeb =[[UIWebView alloc]init];
      }
      [[self webView] loadRequest:[NSURLRequest requestWithURL:url]];
      self.view = nWeb;
    }
错误:

2016-03-13 08:32:39.885 [info][tid:com.facebook.React.JavaScript] Running application "TheNativeMobileWeb" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
2016-03-13 08:32:41.259 TheNativeMobileWeb[82483:9025502] VIEWCONTROLLER YEAH changed
2016-03-13 08:32:41.259 TheNativeMobileWeb[82483:9025502] https://facebook.github.io/react-native/
2016-03-13 08:32:41.259 TheNativeMobileWeb[82483:9025502] https://facebook.github.io/react-native/
1   0x11873ba2e StartWebThread()
2   0x110bb0eaf __pthread_once_handler
3   0x110bc5f13 _os_once
4   0x110bb0e4e pthread_once
5   0x11773925e +[WebView(WebPrivate) enableWebThread]
6   0x117733616 WebKitInitialize
7   0x10ebf3efb ___UIApplicationLoadWebKit_block_invoke
8   0x11087949b _dispatch_client_callout
9   0x110864e28 dispatch_once_f
10  0x10c4dabff _class_initialize
11  0x10c4e0d23 lookUpImpOrForward
12  0x10c4ef8bb objc_msgSend
13  0x10bd73fc0 -[ViewController loadWebView:]
14  0x10bd73db3 -[ViewController loadURL:]
15  0x10bd73cc0 -[ViewController changedURL:]
16  0x10d2a269c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
17  0x10d2a23db _CFXRegistrationPost
18  0x10d2a2142 ___CFXNotificationPost_block_invoke
19  0x10d2e7972 -[_CFXNotificationRegistrar find:object:observer:enumerator:]

url中可能有问题,您可以直接打印url并在浏览器中执行,这样您就可以理解了

你试试这个

    NSString *theOrigString = @"your_url_string";
    NSString *formattedString = [theOrigString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSLog(@"%@", formattedString);

    - (void)loadWebView:(NSURL *)url {
          UIWebView *nWeb = _webView;
          if(nWeb == nil) {
           nWeb =[[UIWebView alloc]init];
           //Set WebView Frame
           nWeb.frame = CGRectMack(0,0,320,480); 
          }
          [nWeb loadRequest:[NSURLRequest requestWithURL:url]];
          self.view = nWeb;
        }
我希望能对你有所帮助