问题看起来像是以popover事件为中心。防爆。我点击相机..它以模态方式启动相机直到屏幕的绝对顶部..如果我点击取消并重复...一切看起来都很完美。现在,如果我选择查看popover相机Roll ..下次启动相机时,它也会从屏幕顶部大约20px,按钮导航栏只有一半可见。 (请记住,标准屏幕具有标准顶部栏,但模态摄像机占据了完整的绝对屏幕1024x768)。
我的代码:
- (IBAction) getPhoto: (id)sender
{
if ([self.popoverController isPopoverVisible]) {
[self.popoverController dismissPopoverAnimated:YES];
}
else if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.allowsEditing = YES;
[self presentModalViewController:imagePicker animated:YES];
}
}
- (IBAction) useCameraRoll: (id)sender
{
if ([self.popoverController isPopoverVisible]) {
[self.popoverController dismissPopoverAnimated:YES];
}
else if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
imagePicker.sourceType =UIImagePickerControllerSourceTypePhotoLibrary;
self.popoverController = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
popoverController.delegate = self;
[self.popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[picker dismissModalViewControllerAnimated:YES];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
[self.popoverController dismissPopoverAnimated:true];
UIImage *savedimage = [editingInfo objectForKey:UIImagePickerControllerOriginalImage];
imageView.image = savedimage;
UIImageWriteToSavedPhotosAlbum (savedimage, self, nil, nil);
}
答案 0 :(得分:0)
我相信当您在弹出窗口中显示UIImagePickerController时,弹出窗口会保留视图并导致一些问题。试图通过破坏popover(及其子视图)或将popover内容设置为nil来从popover释放视图。 防爆。
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage (UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
[self.popoverController setContentViewController:nil];
[self.popoverController dismissPopoverAnimated:true];
UIImage *savedimage = [editingInfo objectForKey:UIImagePickerControllerOriginalImage];
imageView.image = savedimage;
UIImageWriteToSavedPhotosAlbum (savedimage, self, nil, nil);
}