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 回答