UIWebView不再起作用

时间:2013-11-12 12:50:46

标签: ios objective-c uiwebview

我重新编辑了我的问题,我在我的应用程序中设置了我的WebView大约两周,一切都很顺利。昨天我想看看即使我没有更改任何类的代码,并且繁荣SIGABRT,webView是否仍在工作。我从昨天开始就遇到这个bug,并且不明白为什么它仍然给我一个SIGABRT。我确实做了一些改变,但仍然没有任何效果。如果具有目标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

1 个答案:

答案 0 :(得分:1)

将WebViewController的view属性从nib文件连接到File的所有者视图对象。

异常跟踪清楚地显示您的nib视图未连接。