我在UIImagePickerController中遇到了一个相当奇怪的bug。(或者我做错了什么)
我这样加载控制器:
UIImagePickerController*controller = [[UIImagePickerController alloc] init];
controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[controller setDelegate:self];
[firstView presentModalViewController:controller animated:YES];现在的问题是:代码运行得很好,但只有一次。它作为一个动作绑定到一个UIButton上--如果我第二次点击它而不是UIImagePickerController,我会得到一个半透明的(alpha 0.8ish?)黑色的画面出现了,我不能忽视。
我在任何地方都没有创建这样的视图,它只是在该操作中的UIImagePickerController。
我在委托书中忽略了它:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
[firstView dismissModalViewControllerAnimated:YES];
[picker release];
}这也是它应该起的作用。
我做错了什么/这是个bug吗?
发布于 2010-12-22 01:47:50
我相信你想要做的是在现在之后释放控制器:
UIImagePickerController*controller = [[UIImagePickerController alloc] init];
controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[controller setDelegate:self];
[firstView presentModalViewController:controller animated:YES];
// Here...
[controller release];而不是在did结束时:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
[firstView dismissModalViewControllerAnimated:YES];
// Not here...
//[picker release];
}presentModalViewController将在此期间保留控制器并适当地释放它。
https://stackoverflow.com/questions/4500919
复制相似问题