对于密钥pdfView,此类不符合键值编码

时间:2014-01-15 01:20:54

标签: ios objective-c xcode uitableview

我正在制作一个基本的ios应用程序,我试图让用户点击uitableview中的单元格然后打开一个pdf。我遇到了一个奇怪的错误。当我点击单元格时,应用程序崩溃,这是我的错误

014-01-14 20:15:09.782 CCHA App[1171:60b] *** Terminating app due to uncaught exception       'NSUnknownKeyException', reason: '[<PDFDetailViewController 0x15680a10> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key pdfView.'
*** First throw call stack:
(0x3000ef4b 0x3a44f6af 0x3000ec61 0x3094e18b 0x3095fdd5 0x2ff7ee6f 0x32ae0f87 0x32a42917 0x328a4389 0x327861bd 0x32786139 0x329123eb 0x32830273 0x3283007d 0x32830015 0x32781da3 0x32408c6b 0x3240447b 0x3240430d 0x32403d1f 0x32403b2f 0x323fd85d 0x2ffda1cd 0x2ffd7b71 0x2ffd7eb3 0x2ff42c27 0x2ff42a0b 0x34c69283 0x327e6049 0x18269 0x3a957ab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

以下是我的一些代码!

//
//  PDFDetailViewController.h
//  CCHA App
//
//  Created on 1/14/14.
//  Copyright (c) 2014 CCHA. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface PDFDetailViewController : UIViewController {

}
@property (strong, nonatomic) IBOutlet UIWebView *PDFWebView;


@end

//
//  PDFDetailViewController.m
//  CCHA App
//
//  Created  on 1/14/14.
//  Copyright (c) 2014 CCHA. All rights reserved.
//

#import "PDFDetailViewController.h"

@interface PDFDetailViewController ()

@end

@implementation PDFDetailViewController

@synthesize PDFWebView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    NSString *path = [[NSBundle mainBundle] pathForResource:@"TestingDoc" ofType:@"pdf"];
    NSURL *url = [NSURL fileURLWithPath:path];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [PDFWebView loadRequest:request];
    [PDFWebView setScalesPageToFit:YES];

}

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

@end

我无法弄清楚为什么会发生这种情况,我们将非常感谢任何帮助。谢谢!!

2 个答案:

答案 0 :(得分:1)

如果您创建了名为“pdfView”的IBOUTLET,并且稍后将其更改为“PDFWebView”,则会发生这种情况。

查看您的界面构建器。

  1. 选择文件所有者。
  2. 右键单击它。
  3. 将有一个出口将显示警告标志。

答案 1 :(得分:0)

问题可能在您的故事板(或 .xib 文件)中。当名称为pdfView时,您在那里设置了一个插座。然后你将代码中的名称更改为PDFWebView,但是你忘了更改插座的名称,所以现在你的插座坏了,当笔尖加载并且插座名称不再匹配时你会崩溃该物业的名称。