ios - UIWebView 不再工作

标签 ios objective-c uiwebview

我重新编辑了我的问题,我在我的应用程序中设置了我的 WebView 大约两周时间,一切都很顺利。昨天我只想看看 webView 是否仍在工作,即使我没有更改任何类的代码,并且发出 SIGABRT。我从昨天开始就遇到了这个错误,不明白为什么它仍然给我一个 SIGABRT。我按照建议做了一些更改,但仍然没有任何效果。如果在 objective c 方面具有高级技能的人可以帮助我,我快要疯了,这是日志消息(如果需要,我可以显示我的所有代码,请随时编辑答案,以便我可以按顺序评价好的答案帮助我之后的人):

    here is my code :

  - (void)showWebView;
    {
        //here i call my webview in my RootViewController
        ViewController *WebViewVC = [[ViewController alloc] init];
        [[self navigationController] pushViewController:WebViewVC  animated:YES];
        [WebViewVC pushIt];

    }

//here is my WebViewController.h
        #import <UIKit/UIKit.h>
        #import <Foundation/Foundation.h>

    @interface ViewController : UIViewController <UIWebViewDelegate>
    {
         IBOutlet UIWebView *myWebView;
    }

    @property (nonatomic, retain) IBOutlet UIWebView *myWebView;
    -(void)XButton;
    -(void)pushIt;
    @end


    //here is my WebViewController.m
        -(void)pushIt;
    {

        navigation control
        self.navigationItem.hidesBackButton = YES;
        self.navigationItem.leftBarButtonItem = nil;


        self.title = @"*****";
        myWebView = [[UIWebView alloc] initWithFrame:self.view.frame];
        [self.view addSubview:myWebView];
        [self XButton];
        [self WebViewBrowserBackButton];

        NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
        NSString *defaults = [prefs stringForKey:@"myKey"];
        NSString *defaults2 = [prefs stringForKey:@"mySecondKey"];
        NSString *username = defaults; 
        NSString *password = defaults2;
        NSURL* url = [NSURL URLWithString:@"**************"]; 
        NSString* body = [NSString stringWithFormat:@"************",      username,     password];  
        NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url     cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:30];
        request.HTTPMethod = @"POST";
        request.HTTPBody = [body dataUsingEncoding:NSStringEncodingConversionAllowLossy];

        [myWebView loadRequest:request];
    }


  *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "MyWebViewController" nib but the view outlet was not set.'



   *** First throw call stack:
(
    0   CoreFoundation                      0x017e15e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x015648b6 objc_exception_throw + 44
    2   CoreFoundation                      0x017e13bb +[NSException raise:format:] + 139
    3   UIKit                               0x005fd6e6 -[UIViewController _loadViewFromNibNamed:bundle:] + 505
    4   UIKit                               0x005fddad -[UIViewController loadView] + 302
    5   UIKit                               0x005fe0ae -[UIViewController loadViewIfRequired] + 78
    6   UIKit                               0x005fe5b4 -[UIViewController view] + 35
    7   LockScreen                          0x00011596 -[MyWebViewController pushIt] + 246
    8   LockScreen                          0x00003c0a -[RootViewController showWebView] + 202
    9   libobjc.A.dylib                     0x015767d2 -[NSObject performSelector:] + 62
    10  LockScreen                          0x00007f02 -[LCYDataBackedTableView tableView:didSelectRowAtIndexPath:] + 130
    11  UIKit                               0x005cc7b1 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1513
    12  UIKit                               0x005cc924 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 279
    13  UIKit                               0x005d0908 __38-[UITableView touchesEnded:withEvent:]_block_invoke + 43
    14  UIKit                               0x00507183 ___afterCACommitHandler_block_invoke + 15
    15  UIKit                               0x0050712e _applyBlockToCFArrayCopiedToStack + 403
    16  UIKit                               0x00506f5a _afterCACommitHandler + 532
    17  CoreFoundation                      0x017a94ce __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    18  CoreFoundation                      0x017a941f __CFRunLoopDoObservers + 399
    19  CoreFoundation                      0x01787344 __CFRunLoopRun + 1076
    20  CoreFoundation                      0x01786ac3 CFRunLoopRunSpecific + 467
    21  CoreFoundation                      0x017868db CFRunLoopRunInMode + 123
    22  GraphicsServices                    0x02a659e2 GSEventRunModal + 192
    23  GraphicsServices                    0x02a65809 GSEventRun + 104
    24  UIKit                               0x004ead3b UIApplicationMain + 1225
    25  LockScreen                          0x0000297d main + 125
    26  libdyld.dylib                       0x0208970d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

最佳答案

将 WebViewController 的 View 属性从 nib 文件连接到文件所有者的 View 对象。

异常跟踪清楚地表明您在 nib 中的 View 未连接。

关于ios - UIWebView 不再工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19929697/

相关文章:

ios - Xcode Server iOS 触发器问题错误 35

ios - 我想根据距离和时间获取位置经纬度?

ios - 如何在混合代码 Objective-C/C++ 文件(.mm 文件)中使用 PHPhotoLibrary?

使用 iPhone UIWebView 时的 Asp.Net 表单例份验证

javascript - 调整 UIWebView 到它的内容

html - UIWebView中的HTML文件滚动非常慢-Pdf2htmlEX

ios - swift-无法呈现 GameViewController 中的第二个场景

ios - 以编程方式设置/激活 Segue

ios - 如何使用 Core Data 按部分字母顺序对 tableView 中的数据进行排序?

ios - NSArray 按组枚举