是否可以使摄像头选择器看起来像拍摄视频时的样子。
现在是这样:
我想使它看起来像这样:
答案 0 :(得分:0)
您不能完全像UIImagePickerController提供的屏幕截图那样工作,您将需要直接与AVFoundation一起使用并在相机预览周围创建UI。
Apple解释了here的基础知识,像one这样的网络上也有许多教程,它们将向您解释有关拍摄静止或生活照片所需的一切。
编辑:您可以使用UIImagePickerController进行管理
首先需要将showCameraControls属性设置为false。然后,您需要使用带有自己的控件的cameraOverlayView属性添加自己的叠加层(例如,UIButton,它是一个UIView),然后将诸如takePictures()之类的功能分配给您的按钮以拍照。
<?php
include('dbConfig.php');
if(isset($_POST['key'])){
if($_POST['key'] == 'calculate_cost'){
$output="";
$country_id = $_POST["country_id"];
$state_id = $_POST["state_id"];
$city_id = $_POST["city_id"];
$hotel_id = $_POST["hotel_id"];
$food_id = $_POST["food_id"];
$totalCostV = (int)($_POST["totalCostV"]);
$totalCostF = (int)($_POST["totalCostF"]);
$sql = "SELECT cost FROM cost WHERE country_id='$country_id'
AND state_id='$state_id' AND city_id='$city_id'";
$result = mysqli_query($db,$sql);
if(mysqli_num_rows($result) > 0){
$data = mysqli_fetch_array($result);
$totalCostV = $totalCostV + (int)($data["cost"]);
$sql_next = "SELECT
countries.country_name,states.state_name,cities.city_name FROM countries
INNER JOIN states INNER JOIN cities ON countries.country_id =
".$country_id." AND states.state_id= ".$state_id." AND cities.city_id=
".$city_id."";
$result_next = mysqli_query($db,$sql_next);
if($result_next){
$data1 = mysqli_fetch_array($result_next);
}else{
$output.=mysqli_error($db);
}
$query = "SELECT cost FROM foods WHERE
hotel_id='$hotel_id' AND food_id='$food_id'"
$outcome = mysqli_query($db,$query);
if($outcome){
$data2 = mysqli_fetch_array($outcome);
}else{
$output.=mysqli_error($db);
}
$totalCostF = $totalCostF + (int)($data2["cost"]);
$query_next = "SELECT hotels.hotel_name,foods.food_name
FROM hotels INNER JOIN foods ON hotels.hotel_id = ".$hotel_id." AND
foods.food_id= ".$food_id."";
$outcome_next = mysqli_query($db,$query_next);
if($outcome_next){
$data3 = mysqli_fetch_array($outcome_next);
}else{
$output.=mysqli_error($db);
}
$output .= '<tr>
<td>'.$data1["country_name"].'</td>
<td>'.$data1["state_name"].'</td>
<td>'.$data1["city_name"].'</td>
<td>'.$data["cost"].'</td>
<td>'.$data3["hotel_name"].'</td>
<td>'.$data3["food_name"].'</td>
<td>'.$data2["cost"].'</td>
<td><input type="button" value="Cancel"
class="btn btn-danger" style="width: 80px;"></td>
</tr>
';
$jsonArray = array(
'cost' => $output,
//'updation' => $output1,
'total_cost_v' =>$totalCostV,
'total_cost_f' =>$totalCostF
);
echo json_encode($jsonArray);
}
else{
$output.=mysqli_error($db);
}
}
}
?>
相机预览将需要转换为全屏显示(3倍缩放比例很大,但至少在iPhone X上使预览显示为全屏显示,您当然可以对其进行改进):
imagePicker.sourceType = .camera
imagePicker.showsCameraControls = false
imagePicker.delegate = self
imagePicker.cameraOverlayView = yourOverlayWithWithButtons
请注意Apple文档中的cameraOverlayView属性:
仅当图像选择器的源类型设置为UIImagePickerController.SourceType.camera时,才能访问此属性。尝试访问其他源类型的此属性会导致引发invalidArgumentException异常。
看看UIImagePickerController,cameraOverlayView和showCameraControls上的Apple文档。
答案 1 :(得分:0)
只有我能够获得想要的正确效果。