我的界面中有一个按钮,在.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
有人能帮助我吗?我无法理解错误是什么。 感谢
答案 0 :(得分: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 line&amp;只写
[self.navigationController presentViewController:details animated:YES completion:NULL];