UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(dragger.frame.origin.x, dragger.frame.origin.y,dragger.frame.size.width, dragger.frame.size.height)] ;
imgView.image = dragger.image;
overlayView = [[UIView alloc] initWithFrame:CGRectMake(dragger.frame.origin.x,dragger.frame.origin.y,dragger.frame.size.width, dragger.frame.size.height)];
[overlayView addSubview:imgView];
//open the camera
self.picker = [[UIImagePickerController alloc] init];
self.picker.delegate = self;
self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.picker.cameraOverlayView=overlayView;
[self.navigationController presentModalViewController:self.picker animated:YES];这在纵向模式下工作得很好,但在横向模式下叠加图像不会改变。
在我需要帮助的情况下,如何才能做到这一点?
发布于 2011-10-14 13:21:12
你需要注册更改方向...像这样
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(orientationChanged:)
name:@"UIDeviceOrientationDidChangeNotification"
object:nil];然后在同一个类中编写此函数...
- (void) orientationChanged:(NSNotification *)notification{
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
//do stuff
if (orientation==UIDeviceOrientationPortrait) {
imagePickerController.cameraOverlayView = portraitImageView;
}
else if(orientation==UIDeviceOrientationLandscapeLeft)
{
imagePickerController.cameraOverlayView = landscapeImageView;
}
}https://stackoverflow.com/questions/7763283
复制相似问题