2012-12-30 17 views
0

讓我給我的項目提供簡要介紹,我顯示圖片庫中的圖像,我有Imageview和按鈕在我的視圖中控制器,當我按下按鈕時,它將導航到照片庫,當我從庫中選擇照片時,圖像將顯示在圖像視圖中。我得到運行時錯誤有:類不是關鍵值編碼兼容的關鍵圖像

但是,當我運行這個項目,我得到運行時錯誤,請看代碼,並建議我的解決方案,如果我錯過任何文件,請通知我,這樣我就可以上傳你的必要。

我沒有得到確切位置在哪裏錯誤是,我用Google搜索,甚至看到堆棧溢出我仍然無法找到任何解決方案

以下是Viewcontroller.m文件和控制檯查看錯誤和請告訴我

view controller.m 


// 
// ViewController.m 
// ImagePicker 
// 
// Created by Vaibhav on 12/30/12. 
// Copyright (c) 2012 __MyCompanyName__. All rights reserved. 
// 

#import "ViewController.h" 

@implementation ViewController 

@synthesize imagepic; 


-(IBAction)ButtonClicked{ 



    ipc= [UIImagePickerController alloc]; 
    ipc.delegate=self; 

    ipc.sourceType=UIImagePickerControllerSourceTypePhotoLibrary; 

    [self presentModalViewController:ipc animated:YES ]; 



} 

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { 
    imagepic.image= [info objectForKey:UIImagePickerControllerOriginalImage ]; 
    [ [picker parentViewController] dismissModalViewControllerAnimated:YES ]; 

    [picker release]; 


} 
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{ 
    [ [picker parentViewController]dismissModalViewControllerAnimated:YES ]; 
    [picker release]; 
} 



- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Release any cached data, images, etc that aren't in use. 
} 

#pragma mark - View lifecycle 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
} 

- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
    // e.g. self.myOutlet = nil; 
} 

- (void)viewWillAppear:(BOOL)animated 
{ 
    [super viewWillAppear:animated]; 
} 

- (void)viewDidAppear:(BOOL)animated 
{ 
    [super viewDidAppear:animated]; 
} 

- (void)viewWillDisappear:(BOOL)animated 
{ 
    [super viewWillDisappear:animated]; 
} 

- (void)viewDidDisappear:(BOOL)animated 
{ 
    [super viewDidDisappear:animated]; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
} 

@end 

錯誤消息在控制檯:

2012-12-30 13:03:05.758 ImagePicker[1409:f803] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x687b2e0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key image.' 
*** First throw call stack: 
(0x13b9052 0x154ad0a 0x13b8f11 0x9b0032 0x921f7b 0x921eeb 0x93cd60 0x22f91a 0x13bae1a 0x1324821 0x22e46e 0xd5e2c 0xd63a9 0xd65cb 0x36a73 0x36ce2 0x36ea8 0x3dd9a 0xebe6 0xf8a6 0x1e743 0x1f1f8 0x12aa9 0x12a3fa9 0x138d1c5 0x12f2022 0x12f090a 0x12efdb4 0x12efccb 0xf2a7 0x10a9b 0x1d02 0x1c75) 
terminate called throwing an exceptionCurrent language: auto; currently objective-c 
(gdb) 

回答

1

在你ViewController.xib,選擇圖像查看和檢查IBOutlet Connections。如果它連接到名爲imageIBOutlet,請將其刪除。您的圖片視圖應連接到您在.h文件中對應的IBOutlet。您可能已將UIImageView更名爲imagePic,此前爲image

+0

@krish,它解決你的問題嗎? – Atif

+0

是的現在我可以編譯,但在控制檯它顯示我,達爾文「.sharedlibrary apply-load-rules全部 附加到進程1520.我看不到照片庫仍然.. – krish

+0

需要多長時間才能加載? – krish

相關問題