絶対に挫折しないiphoneアプリ開発「超」入門
第6版 swift4&ios11
のチャプター8をやってるのですが、
カメラは起動するのですが、撮った後に出るウインドウが出ず、
imageViewにも画像が反映されません。
下記を参照して多少直しました
画像保存時にエラー(カメラロール)
UIImagePickerControllerOriginalImageに関するエラー
何かわかる方いらっしゃいましたら、ご指摘お願いします。
viewControllerswift
1import UIKit 2 3class ViewController: UIViewController ,UIImagePickerControllerDelegate,UINavigationControllerDelegate{ 4 5 @IBOutlet weak var imageView: UIImageView! 6 @IBAction func launchCamera(_ sender: UIBarButtonItem) { 7 let camera = UIImagePickerController.SourceType.camera 8 if UIImagePickerController.isSourceTypeAvailable(camera){ 9 let picker = UIImagePickerController() 10 picker.sourceType = camera 11 picker.delegate = self 12 self.present(picker,animated:true) 13 14 } 15 } 16 func imagePickerController(_picker:UIImagePickerController,didFinishPickingMediaWithInfo info:[UIImagePickerController.InfoKey:Any]){ 17 let image = info[UIImagePickerController.InfoKey.originalImage] as! UIImage 18 self.imageView.image = image 19 UIImageWriteToSavedPhotosAlbum(image,nil,nil,nil) 20 self.dismiss(animated:true) 21 22 } 23 override func viewDidLoad() { 24 super.viewDidLoad() 25 // Do any additional setup after loading the view, typically from a nib. 26 } 27 28 29} 30
infoplist
1<?xml version="1.0" encoding="UTF-8"?> 2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 3<plist version="1.0"> 4<dict> 5 <key>CFBundleDevelopmentRegion</key> 6 <string>$(DEVELOPMENT_LANGUAGE)</string> 7 <key>CFBundleExecutable</key> 8 <string>$(EXECUTABLE_NAME)</string> 9 <key>CFBundleIdentifier</key> 10 <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> 11 <key>CFBundleInfoDictionaryVersion</key> 12 <string>6.0</string> 13 <key>CFBundleName</key> 14 <string>$(PRODUCT_NAME)</string> 15 <key>CFBundlePackageType</key> 16 <string>APPL</string> 17 <key>CFBundleShortVersionString</key> 18 <string>1.0</string> 19 <key>CFBundleVersion</key> 20 <string>1</string> 21 <key>LSRequiresIPhoneOS</key> 22 <true/> 23 <key>UILaunchStoryboardName</key> 24 <string>LaunchScreen</string> 25 <key>UIMainStoryboardFile</key> 26 <string>Main</string> 27 <key>UIRequiredDeviceCapabilities</key> 28 <array> 29 <string>armv7</string> 30 </array> 31 <key>UISupportedInterfaceOrientations</key> 32 <array> 33 <string>UIInterfaceOrientationPortrait</string> 34 <string>UIInterfaceOrientationLandscapeLeft</string> 35 <string>UIInterfaceOrientationLandscapeRight</string> 36 </array> 37 <key>UISupportedInterfaceOrientations~ipad</key> 38 <array> 39 <string>UIInterfaceOrientationPortrait</string> 40 <string>UIInterfaceOrientationPortraitUpsideDown</string> 41 <string>UIInterfaceOrientationLandscapeLeft</string> 42 <string>UIInterfaceOrientationLandscapeRight</string> 43 </array> 44 <key>NSCameraUsageDescription</key> 45 <string>写真を撮影し、画面に表示します♪</string> 46 <key>NSPhotoLibraryAddUsageDescription</key> 47 <string>これだ</string> 48 <key>NSPhotoLibraryUsageDescription</key> 49 <string>これも</string> 50</dict> 51</plist> 52
error
12019-11-12 22:31:10.744574+0900 Camera[1007:598139] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles 22019-11-12 22:31:10.745657+0900 Camera[1007:598139] [MC] Reading from public effective user settings.
補足情報(FW/ツールのバージョンなど)
imac mid 2010(macos 10.13.6)
xcode 10.1
swift 4.2.1
iphone 5s(ios 12.4.2)
回答1件
あなたの回答
tips
プレビュー