2014-12-11 81 views
0

我已經經歷例如例如嘗試後我的項目與別人比較,看看我在做什麼錯誤,但是我還沒有找到答案。總之,我正在嘗試爲課程做的事情是有三個按鈕分段控制,將改變UIWebView顯示的網址。分段控制,以改變頁的UIWebView

然而,當應用程序是運行它崩潰上推出具有以下控制檯輸出

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x7f969ab2dd80> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key appleWebView.' 
*** First throw call stack: 

以下是我的代碼:

ViewController.M

#import "ViewController.h" 

@interface ViewController() 
@property (weak, nonatomic) IBOutlet UIScrollView *theScroller; 
@property (weak, nonatomic) IBOutlet UISegmentedControl *appleSite1; 
@property (weak, nonatomic) IBOutlet UIWebView *myWebView; 

@end 

@implementation ViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

-(void)viewDidAppear:(BOOL)animated 
{ 
    [super viewDidAppear:animated]; 
    self.theScroller.contentSize = CGSizeMake(280, 1000.0); 
} 

- (IBAction)appleSite1:(UIButton *)sender 
{ 
    NSURL *url = [[NSURL alloc] initWithString:[NSString stringWithFormat:@"http://www.google.com"]]; 

    [self.myWebView loadRequest:[NSURLRequest requestWithURL:url]]; 
} 


@end 

ViewController.h

#import <UIKit/UIKit.h> 

@interface ViewController : UIViewController 
//{ 
// IBOutlet UIWebView myWebView; 
//} 
// 

@end 

我只用一個網站(易趣),直到我可以找出我錯過什麼測試。很顯然,我是一名學生,正在學習,所以請耐心等待。

在此先感謝。

+0

您是否在任何地方創建了UiWebView? – 2014-12-11 06:48:42

回答

0

我不知道你是否已經解決您的問題...

崩潰也許是由這是你的UIWebView鏈接到一個名爲appleWebView屬性(IBOutlet中)Interface Builder中引起的。我認爲你把appleWebView改名爲myWebView

要FIXE這次公開控制器的XIB(或情節串連圖板),選擇的UIWebView,在右側面板打開連接檢查員和刪除鏈接到appleWebView。

希望它有幫助!