ios – 此类不是键值imageView的键值编码兼容

前端之家收集整理的这篇文章主要介绍了ios – 此类不是键值imageView的键值编码兼容前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我的应用程序的RootViewController有问题.当我运行应用程序时,我收到此错误.这意味着什么?
NSUnknownKeyException',reason: '[<UIApplication 0x8634010> setValue:forUndefinedKey:]:     this class is not key value coding-compliant for the key bigImageView.'
 First throw call stack:
 (0x1992012 0x1357e7e 0x1a1afb1 0xe04711 0xd85ec8 0xd859b7 0xdb0428 0x4bc0cc
 0x136b663 0x198d45a 0x4babcf 0x4bc98d 0x29eceb 0x29f002 0x29ded6 0x2af315 0x2b024b 
 0x2a1cf8 0x1dbedf9 0x1dbead0 0x1907bf5 0x1907962 0x1938bb6 0x1937f44 0x1937e1b 0x29d7da 0x29f65c 0x2c6d 0x2b95)   
 libc++abi.dylib: terminate called throwing an exception

我在RootViewController.h中的代码

#import <UIKit/UIKit.h>


  @interface RootViewController : UIViewController <UIGestureRecognizerDelegate>{

  }

 @property (nonatomic,copy)IBOutlet UIImageView * bigImageView;
 @property (nonatomic,assign)BOOL fromRootViewController;


 - (void)handleTap:(UITapGestureRecognizer *)recognizer;



 @end

我在RootViewController.m中的代码

#import "RootViewController.h"
   #import "MenuViewController.h"

  @interface RootViewController ()

   @end

  @implementation RootViewController

  @synthesize bigImageView;
  @synthesize fromRootViewController;

  - (void)viewDidLoad
   {
        [super viewDidLoad];
         UIDeviceOrientation deviceOrientation = [[UIDevice currentDevice]orientation];

          if(deviceOrientation == UIInterfaceOrientationPortrait || deviceOrientation==    UIInterfaceOrientationPortraitUpsideDown) {
    self.bigImageView= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"milanocina_V.png"]];

}
else if (deviceOrientation== UIInterfaceOrientationLandscapeRight){
   self.bigImageView  = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"milanocina_O.png"]];

}
else if (deviceOrientation==UIInterfaceOrientationLandscapeLeft){

    self.bigImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"milanocina_O.png"]];



}

[self.view addSubview:self.bigImageView];

UITapGestureRecognizer * recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
recognizer.delegate = self;
[self.view addGestureRecognizer:recognizer];

}

RootViewController最初调用了ViewController,我更改了名称.可以与错误相关联吗?我能做什么?

解决方法

这是另一种可能性:您重命名了您的类,但忘记更改您的UIViewController初始化代码.对我来说,就是这样:
NewViewController *vc;
vc = [[NewViewController alloc] initWithNibName:@"OldViewController" bundle:nil];

一旦我用@“NewViewController”替换字符串@“OldViewController”,问题就消失了.

原文链接:https://www.f2er.com/iOS/335293.html

猜你在找的iOS相关文章