2012-02-26 2 views
3

私はこの問題を長年にわたって抱えていましたが、スタックオーバーフローの解答を閲覧しましたが、動作していないようです。私はすべての元の接続を削除してから、もう一度接続してみました。すべてが正常にコンパイルが、私はこのエラーを取得しています:もう1つこのクラスは、キーの値に符合しないキー値です。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 

私はまた、私のXIBの絵HERESに私のmain.mに

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 

をSIGABRT 『メッセージ「スレッド1が信号を受信』を取得していますファイル所有者のカスタムクラスは、それがあるべきようのViewControllerに設定されている。

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

私は本当にこの上で助けを必要としてください、それが起こるとなっています2、3日間です。私は最初からプロジェクトを作り直し、運がなかった。私はViewController.hとViewController.mコードを必要に応じて置くことができます。私は "@プロパティ(非原子、保持)IBOutlet UIImageView * imageViewとして宣言されたimageViewを持っている"

助けていただければ幸いです。私は客観的なCとXcodeのプログラミングにまだまだ新しいです。ここ

はViewController.hです:ここ

#import <UIKit/UIKit.h> 

@interface ViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate> 

{ 

BOOL newMedia; 

} 

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

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

@end 

はViewController.mです:

#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

あなたXIBsのいずれかであなたのimageViewコンセントを配線しようとしているように見えますViewControllerではなくUIApplicationに送信してください。私はあなたがそれを配線して、もう一度試してどこからでもコンセントを外すことを提案します。あなたのビューコントローラのXIBのファイルの所有者を右クリックし、ドットをimageViewからイメージビューオブジェクトにドラッグするようにしてください。

更新:

あなたが投稿してプロジェクトを見た、私はあなたの問題があるまさに参照してください。プロジェクト設定で "メインウィンドウXIB"としてViewControllerを設定しました。それを削除しても問題ありません。ただし、ビューではなくViewController.xibのウィンドウもあります。そのウィンドウ内にビューがあるので、そのウィンドウからビューを取り出して、そのウィンドウを削除するだけです。

「メインウィンドウXIB」の設定が混乱している場合は、少し説明してみます。アプリが起動キックます方法は次の2つの方法のいずれかです。

  1. あなたはUIApplicationMain第4パラメータとしてアプリのデリゲートのクラスの名前を渡します。これは1つをインスタンス化し、ウィンドウを作成すると予想されるapplicationDidFinishLaunchingWithOptions:メソッドの間にビューコントローラをrootViewControllerとして設定し、それをキーにして可視にします。

  2. UIApplicationMainにクラス名としてnilを渡し、メインウィンドウXIBを設定します。つまり、XIBがインスタンス化され、その内部にアプリケーションデリゲートのインスタンスがあり、ルートビューコントローラがすべて設定されたウィンドウがあることが期待されます。 "File's Owner"はUIApplicationインスタンスになり、XIBにあるアプリケーションデリゲートオブジェクトにデリゲートアウトレットを設定できます。次にapplicationDidFinishLaunchingWithOptions:で、あなたはmakeキーと目に見えるステップを実行するだけです。

+0

私の "イメージビュー"(imgurリンクを参照してください、それのためのカスタムクラスはUIImageViewですが、私のViewControllerクラスのオプションは与えません)私はそれをViewControllerにクラスを設定しているFile Ownerにリンクしました。 File OwnerとImage Viewの接続をしてくれました。imageView ---------- Image View – Cuchullainn

+0

他にも何か提案がありますか? didFinishLaunchingWithOptionsメソッドのコード?私は本当にthid = sの助けが必要です – Cuchullainn

+0

プロジェクト全体をどこかに置くことができますか? – mattjgalloway

関連する問題