我有一个视图层次结构:
compView 有两个孩子:
bgView
objectView。
我将 objectView 传递给 UIImagePickerController 的 cameraOverlayView 属性。一旦 ImagePicker 完成,我会更新 bgView 中的图像,并且我想继续显示视图树,包括作为 overlayView 传递给 UIImagePickerController 的 objectView。
问题是调用dismissModalViewControllerAnimated关闭UIImagePickerController后,objectView没有出现,好像UIImagePickerContoller隐藏了一样。我检查了调试器,它似乎没有被释放。指针仍然有效。但是视图没有显示。
关于我可能做错了什么的任何想法?
谢谢,艾迪
这里有一些代码向您展示我在做什么:
从 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];
}