此类与键PerformRotate的键值编码不兼容 [英] this class is not key value coding-compliant for the key PerformRotate

查看:81
本文介绍了此类与键PerformRotate的键值编码不兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对编程还比较陌生,我正在使用Xcode编写非常简单的动画.

I am relatively new to programming and I'm using Xcode to code a very simple animation.

这是我的 BuildingViewController.h :

#import <UIKit/UIKit.h>

@interface BuildingViewController : UIViewController {

}
@property (nonatomic, retain) IBOutlet UIButton * buttonTarget;

- (IBAction)performRotate:(id)sender;
//- (void)setValue:(id)value forKey:(NSString *)performRotate;

@end

这是我的BuildingViewController.m

And Here Is My BuildingViewController.m

import "BuildingViewController.h"

@interface BuildingViewController ()

@end

@implementation BuildingViewController

//@synthesize image;


- (void)viewDidLoad
{
//    [image setAlpha:0];
//  [self startAnimation];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)performRotate:(id)sender {

    [UIView animateWithDuration:1.0 animations:^{
    CGAffineTransform previousTransformation = self.buttonTarget.transform;
    CGAffineTransform newRotationTransformation = CGAffineTransformMakeRotation(90.0f * (M_PI / 180.0f));
    CGAffineTransform newTransformation = CGAffineTransformConcat(previousTransformation, newRotationTransformation);
    self.buttonTarget.transform = newTransformation;
}];

}

@end

我得到的错误看起来像这样:

And the error I'm getting looks like this:

2012-10-11 10:08:47.676 graphics1 [27608:c07] *由于未捕获的异常'NSUnknownKeyException'而终止应用程序,原因:'[setValue:forUndefinedKey:]:此类不是键值编码-符合关键PerformRotate." * :第一个引发调用堆栈: (0x1c8e012 0x10cbe7e 0x1d16fb1 0xb78711 0xaf9ec8 0xaf99b7 0xb24428 0x2300cc 0x10df663 0x1c8945a 0x22ebcf 0xf3e37 0xf4418 0xf4648 0xf4882 0x43a25 0x43dbf 0x43f55 0x4cf67 0x10fcc 0x11fab 0x23315 0x2424b 0x15cf8 0x1be9df9 0x1be9ad0 0x1c03bf5 0x1c03962 0x1c34bb6 0x1c33f44 0x1c33e1b 0x117da 0x1365c 0x259d 0x24c5) libc ++ abi.dylib:终止引发异常

2012-10-11 10:08:47.676 graphics1[27608:c07] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key PerformRotate.' * First throw call stack: (0x1c8e012 0x10cbe7e 0x1d16fb1 0xb78711 0xaf9ec8 0xaf99b7 0xb24428 0x2300cc 0x10df663 0x1c8945a 0x22ebcf 0xf3e37 0xf4418 0xf4648 0xf4882 0x43a25 0x43dbf 0x43f55 0x4cf67 0x10fcc 0x11fab 0x23315 0x2424b 0x15cf8 0x1be9df9 0x1be9ad0 0x1c03bf5 0x1c03962 0x1c34bb6 0x1c33f44 0x1c33e1b 0x117da 0x1365c 0x259d 0x24c5) libc++abi.dylib: terminate called throwing an exception

我是否必须篡改 BuildingAppDelegate.h .m ?

推荐答案

检查您的XIB/Storyboard.可能是您的- (IBAction)performRotate:(id)sender方法最初被命名为- (IBAction)PerformRotate:(id)sender,后者是IB中连接的方法.更改方法名称时,必须在XIB/Storyboard中重新连接它,否则它将调用您的旧方法,该方法不再存在.

Check your XIB/Storyboard. Chances are your - (IBAction)performRotate:(id)sender method was originally named - (IBAction)PerformRotate:(id)sender and the latter one is the one connected in IB. When you change the method name, you got to reconnect it in the XIB/Storyboard or it'll call your old method, which no longer exists.

这篇关于此类与键PerformRotate的键值编码不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆