首页 > 其他 > 详细

使用ZXingObjC扫描二维码横竖屏对应

时间:2014-09-03 08:22:16      阅读:234      评论:0      收藏:0      [点我收藏+]
/**
 根据屏幕的方向设置扫描的方向
 * @author maguang
 * @param parameter
 * @return result
 */
- (void)showaCapture
{
    CGAffineTransform transform;
    if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
    {
        self.capture.rotation = 180.0f;
        transform = CGAffineTransformMakeRotation(M_PI/2);
    }
    else if (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {
        self.capture.rotation = 0.0f;
        transform = CGAffineTransformMakeRotation(-M_PI/2);
    }
    else if (self.interfaceOrientation == UIInterfaceOrientationPortrait)
    {
        self.capture.rotation = 90.0f;
        transform = CGAffineTransformMakeRotation(0);
    }
    else if (self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
    {
        self.capture.rotation = 270.0f;
        transform = CGAffineTransformMakeRotation(M_PI);
    }
    
    [self.capture setTransform:transform];
    CGRect f = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
    self.view.layer.frame=f;
    self.capture.layer.frame = f;
}

1、在 - (void)viewWillAppear:(BOOL)animated

方法中调用上面的方法。

2、同时在响应屏幕旋转的方法中调用这个方法。

使用ZXingObjC扫描二维码横竖屏对应

原文:http://www.cnblogs.com/mgbert/p/3952818.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!