2013-12-24 2 views
0

У меня есть приложение, в котором я программно создаю ImageView. Когда я пытаюсь создать это, я получаю ошибку:«setValue: forUndefinedKey:]: этот класс не является ключевым значением, совместимым с кодировкой для ключа« для ImageView

2013-12-23 21:22:13.674 MagnetFall[22343:70b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<GameScreenViewController 0xa98eae0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key backgroundImage.' 
*** First throw call stack: 
(
    0 CoreFoundation      0x019695e4 __exceptionPreprocess + 180 
    1 libobjc.A.dylib      0x016ec8b6 objc_exception_throw + 44 
    2 CoreFoundation      0x019f96a1 -[NSException raise] + 17 
    3 Foundation       0x013ad9ee -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282 
    4 Foundation       0x01319cfb _NSSetUsingKeyValueSetter + 88 
    5 Foundation       0x01319253 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267 
    6 Foundation       0x0137b70a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412 
    7 UIKit        0x006fca15 -[UIRuntimeOutletConnection connect] + 106 
    8 libobjc.A.dylib      0x016fe7d2 -[NSObject performSelector:] + 62 
    9 CoreFoundation      0x01964b6a -[NSArray makeObjectsPerformSelector:] + 314 
    10 UIKit        0x006fb56e -[UINib instantiateWithOwner:options:] + 1417 
    11 UIKit        0x0056d605 -[UIViewController _loadViewFromNibNamed:bundle:] + 280 
    12 UIKit        0x0056ddad -[UIViewController loadView] + 302 
    13 UIKit        0x0056e0ae -[UIViewController loadViewIfRequired] + 78 
    14 UIKit        0x0056e5b4 -[UIViewController view] + 35 
    15 UIKit        0x0057dab9 -[UIViewController shouldAutorotate] + 36 
    16 UIKit        0x0057de01 -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:] + 297 
    17 UIKit        0x008025e5 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:] + 2330 
    18 UIKit        0x0057a0fc -[UIViewController presentViewController:withTransition:completion:] + 6433 
    19 UIKit        0x0057a61f -[UIViewController presentViewController:animated:completion:] + 130 
    20 UIKit        0x0057a65f -[UIViewController presentModalViewController:animated:] + 56 
    21 UIKit        0x0099ee16 -[UIStoryboardModalSegue perform] + 271 
    22 UIKit        0x0098f07e -[UIStoryboardSegueTemplate _perform:] + 174 
    23 UIKit        0x0098f0f9 -[UIStoryboardSegueTemplate perform:] + 115 
    24 libobjc.A.dylib      0x016fe874 -[NSObject performSelector:withObject:withObject:] + 77 
    25 UIKit        0x0045c0c2 -[UIApplication sendAction:to:from:forEvent:] + 108 
    26 UIKit        0x0045c04e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61 
    27 UIKit        0x005540c1 -[UIControl sendAction:to:forEvent:] + 66 
    28 UIKit        0x00554484 -[UIControl _sendActionsForEvents:withEvent:] + 577 
    29 UIKit        0x00553733 -[UIControl touchesEnded:withEvent:] + 641 
    30 UIKit        0x0049951d -[UIWindow _sendTouchesForEvent:] + 852 
    31 UIKit        0x0049a184 -[UIWindow sendEvent:] + 1232 
    32 UIKit        0x0046de86 -[UIApplication sendEvent:] + 242 
    33 UIKit        0x0045818f _UIApplicationHandleEventQueue + 11421 
    34 CoreFoundation      0x018f283f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15 
    35 CoreFoundation      0x018f21cb __CFRunLoopDoSources0 + 235 
    36 CoreFoundation      0x0190f29e __CFRunLoopRun + 910 
    37 CoreFoundation      0x0190eac3 CFRunLoopRunSpecific + 467 
    38 CoreFoundation      0x0190e8db CFRunLoopRunInMode + 123 
    39 GraphicsServices     0x02f1a9e2 GSEventRunModal + 192 
    40 GraphicsServices     0x02f1a809 GSEventRun + 104 
    41 UIKit        0x0045ad3b UIApplicationMain + 1225 
    42 MagnetFall       0x000052dd main + 141 
    43 libdyld.dylib      0x03afe70d start + 1 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 
(lldb) 

Вот код для добавления изображения Вид:

UIImageView *background; 


- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    { //Loads the Background. 
     background = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"BackgroundAll.png"]]; 
     background.center = CGPointMake(160, 284); 
     [self.view addSubview:background]; 

    } 

Try как я мог, я не понял, решение. Помощь будет принята с благодарностью.

+0

Проверьте свой xib-файл и отключите backgroundImage у владельца файла – johnMa

ответ

0

Похоже, что ошибка не имеет ничего общего с фоном. Кажется, что-то не так с вашим xib-файлом.
В вашем файле xib содержится что-то, называемое backgroundImage?

0

Как указано выше, проверьте, не делаете ли вы что-либо с помощью backgroundImage iVar.

0

Вы пытаетесь получить доступ к некоторому виду из вашего xib, но вы не создали его выход.

Смежные вопросы

 Смежные вопросы