我正在尝试创建一个PhotoManager类来处理UIImagePickerController和设置。所以我创建了一个名为PhotoManager的NSObject。为了显示UIImagerPickerController,我获得了对parentView的引用。选择器显示效果很好,但经理没有接到任何委托电话。
但是,如果我将parentView作为委托,那么它会获得委托调用。
这是我拍摄的照片'方法:
-(void) takePhoto{
//Create the image picker control
imagePicker = [[UIImagePickerController alloc] init];
//set the source to the camera dependant on if a camera is avialable
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
}else{
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
//set the delegate
imagePicker.delegate = self;
//show the camera
[parentVC presentViewController:imagePicker animated:YES completion:nil];
}
NSObject可以不从Picker获得委托调用吗?如果代表在不同的对象中呈现,代理人是否可以接听电话?我开始变得非常沮丧。
答案 0 :(得分:2)
一对评论者指出。我根本没有保留对Photomanager
的引用。只要我保留了参考资料,就可以了。