1

.h ファイルで宣言されたインターフェイスにボタンがあります

@interface UserProfileVC : UIViewController <UIImagePickerControllerDelegate>{
    IBOutlet UIButton *camera;
}
@property (nonatomic,retain) IBOutlet UIButton *camera;
-(IBAction)cameraPress:(id)sender;

そして、私の .m ファイルには次のものがあります。

-(IBAction)cameraPress:(id)sender{
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
//  [picker setDelegate:self];
    [picker setAllowsEditing:YES];
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    [self presentModalViewController:picker animated:YES];
    [picker release];
}

しかし、私はこのエラーがあります:

*** -[UserProfileVC performSelector:withObject:withObject:]: message sent to deallocated instance 0x7bc2a40

誰かが私を助けることができますか?何が間違っているのか理解できません。ありがとう

4

1 に答える 1

0

前回のコメントのコードによると、

-(void)showDetails:(id)sender{ 
NSLog(@"Annotation Click"); 
details= [[UserProfileVC alloc] initWithNibName: @"Details" bundle:nil ]; 
details.Nome=note.title; 
addNavigationController = [[UINavigationController alloc] initWithRootViewController:details]; 
[self.navigationController presentModalViewController:addNavigationController animated:YES]; 
}

次のことをお勧めします。UIViewControllerクラスリファレンスドキュメントを見ると、以下のメモがあります

presentModalViewController:animated:

指定されたビュー コントローラーによって管理されるモーダル ビューをユーザーに表示します。(非推奨presentViewController:animated:completion:代わりに使用してください。)

ですので、ご利用をお勧めしますpresentViewController:animated:completion。「割り当て解除されたインスタンスにメッセージが送信されました」というエラーに関連しているとは思いませんが、問題を解決できるかどうかを確認してください。

また、なぜあなたがこの行を書いたのかわかりません

addNavigationController = [[UINavigationController alloc] initWithRootViewController:details]; 

UserProfileVC単に現在の状態で表示したい場合はUINavigationController、 addNavigationController 行を削除して書き込みのみを行うことをお勧めします

[self.navigationController presentViewController:details animated:YES completion:NULL];
于 2012-06-13T06:48:08.507 に答える