2012-02-26 3 views
3

나는이 문제에 오래 동안 갇혀 있었고 스택 오버플로에 대한 답변을 살펴 보았지만 작동하지 않는 것 같습니다. 원래 연결을 모두 삭제 한 다음 다시 연결해 보았습니다. 모든 것이 잘 컴파일하지만 난이 오류가 점점 오전 :또 다른이 클래스는 키 값을 코딩하는 키 값이 아닙니다. imageView

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x6a067d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key imageView.' 
*** First throw call stack: 
(0x11e4052 0x1375d0a 0x11e3f11 0xa4c032 0x9bdf7b 0x9bdeeb 0x9d8d60 0x2cb91a 0x11e5e1a 0x114f821 0x2ca46e 0x2cc010 0xac14a 0xac461 0xab7c0 0xba743 0xbb1f8 0xaeaa9 0x1c84fa9 0x11b81c5 0x111d022 0x111b90a 0x111adb4 0x111accb 0xab2a7 0xaca9b 0x2072 0x1fe5) 
terminate called throwing an exception 

나는 또한 내 main.m을 heres

0x000ac97f <+0891> mov %eax,(%esp) 
0x000ac982 <+0894> call 0x5478b2 <dyld_stub_objc_msgSend> 
0x000ac987 <+0899> mov %eax,%esi 
0x000ac989 <+0901> mov 0x69940e(%edi),%eax 
0x000ac98f <+0907> mov 0x68db46(%edi),%ecx 
0x000ac995 <+0913> lea 0x525009(%edi),%edx 
0x000ac99b <+0919> mov %edx,0x8(%esp) 
0x000ac99f <+0923> mov %ecx,0x4(%esp) 
0x000ac9a3 <+0927> mov %eax,(%esp) 
0x000ac9a6 <+0930> call 0x5478b2 <dyld_stub_objc_msgSend> 
0x000ac9ab <+0935> mov 0x68df86(%edi),%ecx 
0x000ac9b1 <+0941> mov %ebx,0x18(%esp) 
0x000ac9b5 <+0945> lea 0x6a6c56(%edi),%edx 
0x000ac9bb <+0951> mov %edx,0x14(%esp) 
0x000ac9bf <+0955> mov %eax,0xc(%esp) 
0x000ac9c3 <+0959> mov %esi,0x8(%esp) 
0x000ac9c7 <+0963> mov %ecx,0x4(%esp) 
0x000ac9cb <+0967> mov -0x18(%ebp),%eax 
0x000ac9ce <+0970> mov %eax,(%esp) 
0x000ac9d1 <+0973> movl $0x641,0x10(%esp) 
0x000ac9d9 <+0981> call 0x5478b2 <dyld_stub_objc_msgSend> 
0x000ac9de <+0986> mov 0x699476(%edi),%eax 
0x000ac9e4 <+0992> mov 0x68db72(%edi),%ecx 
0x000ac9ea <+0998> mov %ecx,0x4(%esp) 
0x000ac9ee <+1002> mov %eax,(%esp) 
0x000ac9f1 <+1005> call 0x5478b2 <dyld_stub_objc_msgSend> 
0x000ac9f6 <+1010> mov 0x68df92(%edi),%ecx 
0x000ac9fc <+1016> mov %eax,0x8(%esp) 
0x000aca00 <+1020> mov %ecx,0x4(%esp) 
0x000aca04 <+1024> mov -0x10(%ebp),%esi 
0x000aca07 <+1027> mov %esi,(%esp) 
0x000aca0a <+1030> call 0x5478b2 <dyld_stub_objc_msgSend> 
0x000aca0f <+1035> mov 0x6d0fbe(%edi),%ebx 
0x000aca15 <+1041> test %al,%al 
0x000aca17 <+1043> je  0xaca2c <UIApplicationMain+1064> 
0x000aca19 <+1045> mov 0x68dbb6(%edi),%eax 
0x000aca1f <+1051> mov %ebx,0x8(%esp) 
0x000aca23 <+1055> mov %eax,0x4(%esp) 
0x000aca27 <+1059> mov %ebx,(%esp) 
0x000aca2a <+1062> jmp 0xaca69 <UIApplicationMain+1125> 
0x000aca2c <+1064> mov 0x68dc0a(%edi),%eax 
0x000aca32 <+1070> mov %eax,0x4(%esp) 
0x000aca36 <+1074> mov %esi,(%esp) 
0x000aca39 <+1077> call 0x5478b2 <dyld_stub_objc_msgSend> 
0x000aca3e <+1082> mov 0x68dcba(%edi),%ecx 
0x000aca44 <+1088> mov %ecx,0x4(%esp) 
0x000aca48 <+1092> mov %eax,(%esp) 
0x000aca4b <+1095> call 0x5478b2 <dyld_stub_objc_msgSend> 
0x000aca50 <+1100> mov 0x68df96(%edi),%ecx 
0x000aca56 <+1106> mov %eax,0x8(%esp) 
0x000aca5a <+1110> mov %ecx,0x4(%esp) 
0x000aca5e <+1114> mov %ebx,(%esp) 
0x000aca61 <+1117> movl $0x1,0xc(%esp) 
0x000aca69 <+1125> call 0x5478b2 <dyld_stub_objc_msgSend> 
0x000aca6e <+1130> mov 0x68db22(%edi),%eax 
0x000aca74 <+1136> mov %eax,0x4(%esp) 
0x000aca78 <+1140> mov -0x14(%ebp),%eax 
0x000aca7b <+1143> mov %eax,(%esp) 
0x000aca7e <+1146> call 0x5478b2 <dyld_stub_objc_msgSend> 
0x000aca83 <+1151> mov 0x6d0fbe(%edi),%eax 
0x000aca89 <+1157> mov 0x68df9a(%edi),%ecx 
0x000aca8f <+1163> mov %ecx,0x4(%esp) 
0x000aca93 <+1167> mov %eax,(%esp) 
0x000aca96 <+1170> call 0x5478b2 <dyld_stub_objc_msgSend> 
0x000aca9b <+1175> xor %eax,%eax 
0x000aca9d <+1177> add $0x2c,%esp 
0x000acaa0 <+1180> pop %esi 
0x000acaa1 <+1181> pop %edi 
0x000acaa2 <+1182> pop %ebx 
0x000acaa3 <+1183> pop %ebp 
0x000acaa4 <+1184> ret 

내 XIB의 사진에 SIGABRT "메시지"스레드 1이 신호를받은 "점점 오전을, 파일 소유자의 사용자 정의 클래스는 그것이 있어야처럼의 ViewController로 설정되어 있습니다.

http://i.imgur.com/aqFo9.png

내가 정말 일이있다,이에 도움이 필요하세요 며칠 동안. 나는 처음부터 프로젝트를 다시 만들고 행운이 없었다. 필요한 경우 내 ViewController.h 및 ViewController.m 코드를 넣을 수 있습니다. "@ 속성 (nonatomic, 보유) IBOutlet UIImageView * imageView;"로 선언 된 imageView가 있습니다.

도움을 주시면 대단히 감사하겠습니다. 나는 객관적인 C와 Xcode에서 여전히 프로그래밍에 익숙하지 않다. 여기

#import <UIKit/UIKit.h> 

@interface ViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate> 

{ 

BOOL newMedia; 

} 

@property (nonatomic, retain) IBOutlet UIImageView *imageView; 

- (IBAction) useCamera; 
- (IBAction) useCameraRoll; 

@end 

가 ViewController.m입니다 : 여기

는 ViewController.h 당신이 당신의 XIBs 중 하나를 사용하여 imageView 콘센트를 연결할하려는처럼

#import "ViewController.h" 
#import "MobileCoreServices/UTCoreTypes.h" 

@implementation ViewController 

@synthesize imageView; 

- (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 
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
} else { 
    return YES; 
} 
} 

-(void)imagePickerController:(UIImagePickerController *)picker 
didFinishPickingMediaWithInfo:(NSDictionary *)info 
{ 
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType]; 

[self dismissModalViewControllerAnimated:YES]; 

if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) { 
    UIImage *image = [info 
         objectForKey:UIImagePickerControllerOriginalImage]; 

    imageView.image = image; 

    if (newMedia) 
     UIImageWriteToSavedPhotosAlbum(image, 
             self, 
             @selector(image:finishedSavingWithError:contextInfo:), 
             nil); 
} 
else if ([mediaType isEqualToString:(NSString *)kUTTypeMovie]) 
{ 
    // Code here to support video if enabled 
} 
} 

-(void)image:(UIImage *)image 
finishedSavingWithError:(NSError *)error 
contextInfo:(void *)contextInfo 
{ 
if (error) { 
    UIAlertView *alert = [[UIAlertView alloc] 
          initWithTitle: @"Save failed" 
          message: @"Failed to save image" 
          delegate: nil 
          cancelButtonTitle:@"OK" 
          otherButtonTitles:nil]; 
    [alert show]; 
    [alert release]; 
} 
} 


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

- (IBAction) useCamera 

{ 
if ([UIImagePickerController isSourceTypeAvailable: 
    UIImagePickerControllerSourceTypeCamera]) 
{ 
    NSLog(@"you reached here for camera"); 

    UIImagePickerController *imagePicker = 
    [[UIImagePickerController alloc] init]; 
    imagePicker.delegate = self; 
    imagePicker.sourceType = 
    UIImagePickerControllerSourceTypeCamera; 
    imagePicker.mediaTypes = [NSArray arrayWithObjects: 
           (NSString *) kUTTypeImage, 
           nil]; 
    imagePicker.allowsEditing = NO; 
    [self presentModalViewController:imagePicker animated:YES]; 
    [imagePicker release]; 
    newMedia = YES; 
} 



} 


- (IBAction) useCameraRoll 

{ 
    if ([UIImagePickerController isSourceTypeAvailable: 
     UIImagePickerControllerSourceTypeSavedPhotosAlbum]) 
{ 
    NSLog(@"you reached here for camera roll"); 

    UIImagePickerController *imagePicker = 
    [[UIImagePickerController alloc] init]; 
    imagePicker.delegate = self; 
    imagePicker.sourceType = 
    UIImagePickerControllerSourceTypePhotoLibrary; 
    imagePicker.mediaTypes = [NSArray arrayWithObjects: 
           (NSString *) kUTTypeImage, 
           nil]; 
    imagePicker.allowsEditing = NO; 
    [self presentModalViewController:imagePicker animated:YES]; 
    [imagePicker release]; 
    newMedia = NO; 
} 

} 






@end 
+0

실제로이보기 컨트롤러를 만들 때 코드를 포함 할 수 있습니까? 주 창 xib 또는 스토리 보드가없는 것 같아서 코드로 만들겠습니까? – jrturton

+0

http://stackoverflow.com/questions/4779561/nsunknownkeyexception – Max

+0

저는 window.xib가 없습니다. ViewController.xib라는 하나가 있습니다. 이제는 ViewController.h와 .m을 올려 놓을 것입니다. – Cuchullainn

답변

5

같습니다 ViewController 대신 UIApplication으로 변경하십시오. 나는 당신이 그것을 배선하고 다시 시도하는 곳에서 콘센트를 제거하는 것이 좋습니다. 보기 컨트롤러의 XIB 파일 소유자를 마우스 오른쪽 단추로 확인하고 거기에 imageView에서 점을 이미지보기 개체로 끕니다.

업데이트 :

은 당신이 게시 프로젝트 보았다 데, 나는 당신의 문제가 정확히 무엇을 참조하십시오. 프로젝트 설정에서 ViewController을 "메인 윈도우 XIB"로 설정했습니다. 그것을 제거하면 모든 것이 정상입니다. 그러나보기가 아닌 ViewController.xib에도 창이 있습니다. 해당 창 내부에서보기가 있으므로 해당 창에서보기를 가져 와서 창을 삭제하십시오.

"Main Window XIB"설정에 혼란이 있다면 조금 설명해 보겠습니다. 응용 프로그램이 시작 킥 도착하는 방법은 두 가지 방법 중 하나입니다

  1. 당신은 UIApplicationMain에 네 번째 매개 변수로 앱 위임의 클래스의 이름을 전달합니다. 이것은 하나를 인스턴스화 한 다음 창을 생성 할 것으로 예상되는 applicationDidFinishLaunchingWithOptions: 메서드 중에 뷰 컨트롤러를 rootViewController으로 설정하고 키와 표시로 만듭니다.

  2. UIApplicationMain에 클래스 이름으로 nil을 전달하고 기본 창 XIB를 설정합니다. 즉, XIB가 인스턴스화되고 내부에 앱 대리인의 인스턴스가 있고 루트보기 컨트롤러가있는 창이 모두 설정되어 있어야합니다. "File 's Owner"는 UIApplication 인스턴스가 될 것이고 XIB에있는 응용 프로그램 위임 개체에 대리자 콘센트를 설정할 수 있습니다.그런 다음 applicationDidFinishLaunchingWithOptions:에서 make 키와 가시적 인 단계 만 수행하면됩니다.

+0

내 "이미지보기"(imgur 링크 참조, UIImageView에 대한 사용자 정의 클래스이지만 내 ViewController 클래스에 대한 옵션을 제공하지 않습니다.) ViewController 클래스를 설정 한 파일 소유자에 링크했습니다. File Owner와 Image View 사이의 연결을 완료했습니다. imageView ---------- Image View – Cuchullainn

+0

다른 어떤 제안이 있습니까? didFinishLaunchingWithOptions 메소드 코드? 정말 thid = s에 대한 도움이 필요합니다. – Cuchullainn

+0

전체 프로젝트를 어딘가에 넣을 수 있습니까? – mattjgalloway

관련 문제