开发者

Re-using the UIImagePickerController.cameraOverlayView

开发者 https://www.devze.com 2022-12-15 00:43 出处:网络
I have a hierarchy of views: compViewwith two children: bgView objectView. I\'m passing objectView to the cameraOverlayView property of the UIImagePickerController. Once the ImagePicker is done I upd

I have a hierarchy of views:

compView with two children:

bgView

objectView.

I'm passing objectView to the cameraOverlayView property of the UIImagePickerController. Once the ImagePicker is done I update the image in the bgView and I would like to continue to display the view tree including the objectView which was passed to the UIImagePickerController as an overlayView.

The problem is that after calling dismissModalViewControllerAnimated to close the UIImagePickerController, the objectView is not appearing, as if the UIImagePickerContoller is hiding it. I checked in the debugger and it doesn't seem to be dealocated. The pointer is still valid. But the view is not showing.

Any ideas of what I might be doing wrong?

Thanks, Eddy

Here a bit of code to show you what I'm doing:

From myViewController.m:

- (void)loadView {
 CGRect rect = self.navigationController.view.bounds;
 compView = [[UIView alloc] initWithFrame:rect];
 bgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Storage/dummy_bg.png"]];

 objectView = [[PropImageView开发者_运维技巧 alloc] initWithImage:[UIImage imageNamed:@"Storage/rasta.png"]];

 [objectView setUserInteractionEnabled:YES];
 [objectView setMultipleTouchEnabled:YES];
 [compView addSubview:bgView];
 [compView addSubview:objectView];
 self.view = compView;
 [self placeObject];
 [objectView release];
 [bgView release];
 [compView release];

}

- (void) placeObject
{
 NSLog(@"camera button pressed");

 // make sure camera is avaialble before setting it as source
 //

 if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
#if !TARGET_IPHONE_SIMULATOR
  UIImagePickerController* picker = [[UIImagePickerController alloc] init];

  picker.sourceType = UIImagePickerControllerSourceTypeCamera; 

  picker.delegate = self;
  picker.allowsEditing = NO;
  picker.view.hidden = NO;
  picker.cameraOverlayView = objectView;
  [self presentModalViewController:picker animated:NO];
  [picker release];

#endif
 }


// from PickImageAppDelegate.m
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
 // Dismiss the image selection, hide the picker and
 [picker dismissModalViewControllerAnimated:YES];  
 bgView.image = [self rotateImage:image byOrientationFlag:UIImageOrientationRight];
}


[picker dismissModalViewControllerAnimated:YES];

That should be

[self dismissModalViewControllerAnimated:YES];

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号