2012-10-11 31 views
2

我是相對較新的編程和我使用Xcode編碼一個非常簡單的動畫。這個類不是密鑰編碼兼容的關鍵PerformRotate

這是我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

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 

而且我得到看起來像這樣的錯誤:

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:終止叫做拋出異常

我必須與BuildingAppDelegate.h.M篡改?

回答

11

檢查您的XIB/Storyboard。機會是你的- (IBAction)performRotate:(id)sender方法最初被命名爲- (IBAction)PerformRotate:(id)sender,後者是在IB連接的。當您更改方法名稱時,必須在XIB/Storyboard中重新連接它,否則它會調用舊的方法,該方法不再存在。

+0

謝謝你這麼多我一直在篡改那整天 –

+1

沒問題。這是你學習之前需要弄錯的那些晦澀難懂的事情之一。請接受我的答案,如果它解決了你的問題。 – yuf

+2

+1好答案! @NikitaJerschow如果解決了這個問題,可以考慮通過點擊複選標記的灰色輪廓來接受這個答案。這將告訴其他人您不再尋找改進的解決方案,併爲您獲得堆棧溢出的全新徽章。 – dasblinkenlight

相關問題