我正在开发条形码阅读器应用程序,我想通过点击相机来缩放相机视图。我使用以下方法来缩放相机视图,但它不适用于iOS6和iPhone4(iOS7)设备。请任何人帮助我:
if ([self.device respondsToSelector:@selector(setActiveFormat:)] &&
[self.device.activeFormat respondsToSelector:@selector(videoMaxZoomFactor)] &&
[self.device respondsToSelector:@selector(setVideoZoomFactor:)]){
float maxZoom = 0;
if ([self.device.activeFormat respondsToSelector:@selector(videoZoomFactorUpscaleThreshold)]){
maxZoom = self.device.activeFormat.videoZoomFactorUpscaleThreshold;
} else {
maxZoom = self.device.activeFormat.videoMaxZoomFactor;
}
float maxZoomTotal = self.device.activeFormat.videoMaxZoomFactor;
// maxZoom =2.0;
// maxZoomTotal = maxZoomTotal +2;
if ([self.device respondsToSelector:@selector(setVideoZoomFactor:)] && maxZoomTotal > 1.1){
videoZoomSupported = true;
if (param_ZoomLevel1 != 0 && param_ZoomLevel2 != 0){
if (param_ZoomLevel1 > maxZoomTotal * 100){
param_ZoomLevel1 = (int)(maxZoomTotal * 100);
}
if (param_ZoomLevel2 > maxZoomTotal * 100){
param_ZoomLevel2 = (int)(maxZoomTotal * 100);
}
firstZoom = 0.01 * param_ZoomLevel1;
secondZoom = 0.01 * param_ZoomLevel2;
} else {
if (maxZoomTotal > 2){
if (maxZoom > 1.0 && maxZoom <= 2.0){
firstZoom = maxZoom;
secondZoom = maxZoom * 2;
} else
if (maxZoom > 2.0){
firstZoom = 2.0;
secondZoom = 4.0;
}
}
}
} else {
}