在Xcode 中不管是 iPhone 或 iPad 模擬器都不能使用照相機功能,
如果一定得要在撰寫程式時加上使用照相機的功能,
最好在 UIImagePickerControllerSourceType.Camera 這行之前加上一個 if 判斷, 如
if UIImagePickerController.isSourceTypeAvailable(.Camera) {
// Camera 可以正常使用時
} else {
print("Camera is not available.")
}
如果不加上這個 if 判斷, 在模擬器中按到 Camera 功能時,
程式就會 crashed.