我一直在通过示例尝试将我的项目与其他人进行比较,以查看我做错了什么,但是我还没有找到答案。简而言之,我试图为课堂做的是有一个三按钮分段控件,它将更改UIWebView
显示的 url。
但是,当应用程序运行时,它会在启动时崩溃,并显示以下控制台输出
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:
以下是我的代码:
视图控制器.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
视图控制器.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
//{
// IBOutlet UIWebView myWebView;
//}
//
@end
我只在一个站点(ebay)上进行测试,直到我能弄清楚我到底错过了什么。显然我是一名学生并且正在学习,所以请多多包涵。
提前致谢。