我试图让用户上传图片并创建一个帐户。然而,在选择图像之后,用户应该选择“创建帐户”。但是程序停止了,之后什么也没做。然后,此消息显示在编译器中,“创建具有未知类型的图像格式是一个错误,没有上传图像。”
这是代码。
<?php
$sqlteams = "SELECT * FROM tournaments where status='Active'";
$sqlquery = mysqli_query($cnn,$sqlteams);
while($rsres = mysqli_fetch_array($sqlquery))
{
(line 47) if($rsres["tournamentid"]== $_GET["tournamentid"])
{
echo "<option value='$rsres[tournamentid]' selected>$rsres[name]</option>";
}
else
{
echo "<option value='$rsres[tournamentid]'>$rsres[name]</option>";
}
}
?>
很抱歉,如果这太多了,但我不确定在哪里确定此错误,因为Xcode没有将其显示为错误。似乎解决方案可能在某个地方here,但我找不到它。提前谢谢。
答案 0 :(得分:0)
您可以使用availableMediaTypes
确保仅显示有效的图片类型。
let type = kUTTypeImage as String
let imagePicker = UIImagePickerController()
if UIImagePickerController.isSourceTypeAvailable(.camera) {
if let availableTypes = UIImagePickerController.availableMediaTypes(for: .camera) {
if availableTypes.contains(type) {
imagePicker.mediaTypes = [type]
imagePicker.sourceType = UIImagePickerControllerSourceType.camera
}
}
} else {
return
}
imagePicker.allowsEditing = true
imagePicker.showsCameraControls = true
imagePicker.delegate = self
然后您也可以查看UIImagePickerControllerOriginalImage
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
if let image = info[UIImagePickerControllerOriginalImage] as? UIImage ?? info[UIImagePickerControllerEditedImage] as? UIImage {
userImagePicker.image = image
imageSelected = true
} else {
print("image wasnt selected")
}
imagePicker.dismiss(animated: true, completion: nil)
}