2012-10-03 18 views
5

Uygulamamın RootViewController ile ilgili bir sorunum var. Uygulamayı çalıştırdığımda bu hatayı alıyorum. Ne anlama geliyor?Bu sınıf anahtar resim için anahtar kodlama uyumlu değilViewView

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.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 içinde 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 

Kodum Benim kod başlangıçta ViewController aradı ve adını değiştirdik. Hata ile ilişkilendirilebilir mi? Ne yapabilirim?

+1

Hata iletisinin, bu özelliği "UIApplication" ile ayarladığınızı söylediğini farkettiniz ... Dünyanın tüm kodu 'RootViewController' ile fark yaratmayacaksınız. Bahse girerim XIB dosyanızda hatalı bir bağlantı var. Kötü bağlantılar, az açıklama noktaları ile görünecektir. – borrrden

+0

Kötü bağlantıyı nasıl bulurum? –

+0

Sorunun bu soruna neden olup olmadığını bilmiyorum, ancak bigImageView ile yanlış bir şeyler yapıyorsunuz. Bunu bir IBOutlet olarak tanımlarsınız, ancak kodda oluşturulan örneklere atarsınız. Eğer IB'de var olan bir ImageView'a takıyorsanız, kod bunu geçersiz kılacaktır. Oryantasyona bağlı olarak farklı şeyler olması gerektiğinden muhtemelen bir IBOutlet olmamalıdır. – rdelmar

cevap

3

İşte başka bir olasılık: Sınıfınızı yeniden adlandırdınız, ancak UIViewController başlatma kodunuzu değiştirmeyi unutmuştunuz. Ben @ "NewViewController" ile "OldViewController" @ dize yerini kez

NewViewController *vc; 
vc = [[NewViewController alloc] initWithNibName:@"OldViewController" bundle:nil]; 

, sorun ortadan kalktı: Benim için bu oldu.

14

Bir noktada, bir @property ayarlayın. Daha sonra onu kodunuzdan sildiniz, ancak xib/storyboard'unuzdan çıkartmadınız. Hikaye panonuzda bulmanız, sağ tıklamanız ve çıkışı silmeniz gerekir.

İlgili konular