首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iPhone相机重叠式图像定向中的问题

iPhone相机重叠式图像定向中的问题
EN

Stack Overflow用户
提问于 2011-10-14 13:07:29
回答 1查看 582关注 0票数 0
代码语言:javascript
复制
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];

这在纵向模式下工作得很好,但在横向模式下叠加图像不会改变。

在我需要帮助的情况下,如何才能做到这一点?

EN

回答 1

Stack Overflow用户

发布于 2011-10-14 13:21:12

你需要注册更改方向...像这样

代码语言:javascript
复制
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(orientationChanged:)
                                                 name:@"UIDeviceOrientationDidChangeNotification" 
                                               object:nil];

然后在同一个类中编写此函数...

代码语言:javascript
复制
- (void) orientationChanged:(NSNotification *)notification{  
    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];

    //do stuff

    if (orientation==UIDeviceOrientationPortrait) {
        imagePickerController.cameraOverlayView = portraitImageView;

    }

    else if(orientation==UIDeviceOrientationLandscapeLeft)
    {

        imagePickerController.cameraOverlayView = landscapeImageView;

    }

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7763283

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档