首页 > 代码库 > 使用ZXingObjC扫描二维码横竖屏对应
使用ZXingObjC扫描二维码横竖屏对应
/** 根据屏幕的方向设置扫描的方向 * @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扫描二维码横竖屏对应
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。