前提・実現したいこと
いつもお世話になっております。
動画撮影アプリの申請を行った結果、「Guideline 2.1 - Performance - App Completeness」にてリジェクトとなりました。
内容を確認したところ、iPad互換表示の際に、初回起動時のカメラデバイス使用許可モーダル後にプレビューが表示されず、
画面が真っ暗になるとの指摘でした。
しかしながら、当方iPadの実機を所持しておらず、シミュレータではカメラ使用アプリの確認はできないため、
下記コードにおいて、何かiPadでプレビューが表示されなくなりそうな要素はございますでしょうか。
当方で所有しているiPhone8及びiPhoneSEでの実機確認では、問題なくプレビューが表示されておりました。
申請の際には、Devicesを「Universal」ではなく、「iPhone」にして申請しています。
お手数をおかけいたしますが、ご教示をいただけますようよろしくお願いいたします。
発生している問題・エラーメッセージ
以下、Appleからのメッセージ原文です。添付されていたスクリーンショットも貼ります。
We discovered one or more bugs in your app when reviewed on iPad running iOS 12.3.1 on Wi-Fi.
Specifically, we only encountered a blank black screen while attempting to record video for use in your app. This occurred after accepting the modal alerts for access to the device’s camera.
Next Steps
To resolve this issue, please run your app on a device to identify any issues, then revise and resubmit your app for review.
If we misunderstood the intended behavior of your app, please reply to this message in Resolution Center to provide information on how these features were intended to work.
For new apps, uninstall all previous versions of your app from a device, then install and follow the steps to reproduce the issue. For updates, install the new version as an update to the previous version, then follow the steps to reproduce the issue.
該当のソースコード
ViewController
1import UIKit 2import AVFoundation 3import Photos 4 5class ViewController: UIViewController, AVCaptureFileOutputRecordingDelegate { 6 7 var session: AVCaptureSession! 8 var videoDevice: AVCaptureDevice! 9 var audioDevice: AVCaptureDevice! 10 var fileOutput: AVCaptureFileOutput! 11 12 var recordButton: UIButton! 13 var settingButton: UIButton! 14 let settingButtonImage: UIImage = UIImage(named: "setting")! 15 16 var isRecording = false 17 18 override func viewDidLoad() { 19 super.viewDidLoad() 20 21 session = AVCaptureSession() 22 videoDevice = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back) 23 let videoInput = try! AVCaptureDeviceInput.init(device: videoDevice) 24 session.addInput(videoInput) 25 26 audioDevice = AVCaptureDevice.default(for: .audio) 27 let audioInput = try! AVCaptureDeviceInput.init(device: audioDevice) 28 session.addInput(audioInput) 29 30 fileOutput = AVCaptureMovieFileOutput() 31 session.addOutput(fileOutput) 32 33 session.startRunning() 34 35 setUpPreview() 36 setUpRecordingButton() 37 setUpSettingButton() 38 39 } 40 41 private func setUpPreview() { 42 let videoLayer: AVCaptureVideoPreviewLayer = AVCaptureVideoPreviewLayer(session: session) 43 videoLayer.frame = self.view.bounds 44 videoLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill 45 self.view.layer.addSublayer(videoLayer) 46 } 47 48 private func startRecording() { 49 let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true) 50 let documentDirectory = paths[0] as String 51 let formatter = DateFormatter() 52 formatter.dateFormat = "yyyyMMddHHmmSS" 53 let filePath: String? = "(documentDirectory)/video-(formatter.string(from: Date())).mp4" 54 let fileURL = NSURL(fileURLWithPath: filePath!) 55 56 print("録画開始") 57 fileOutput?.startRecording(to: fileURL as URL, recordingDelegate: self) 58 recordButton.setTitle("■", for: UIControl.State.normal) 59 } 60 61 private func stopRecording() { 62 print("録画停止") 63 fileOutput?.stopRecording() 64 recordButton.setTitle("●", for: UIControl.State.normal) 65 } 66 67 func fileOutput(_ output: AVCaptureFileOutput, didFinishRecordingTo outputFileURL: URL, from connections: [AVCaptureConnection], error: Error?) { 68 PHPhotoLibrary.shared().performChanges({ 69 PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: outputFileURL) 70 }) { (isCompleted, error) in 71 if isCompleted { 72 print("録画完了") 73 } 74 } 75 } 76 77 // Setting to make a recording button 78 func setUpRecordingButton() { 79 recordButton = UIButton(frame: CGRect(x: 0, y: 0, width: 70, height: 70)) 80 recordButton.backgroundColor = UIColor.red 81 recordButton.layer.masksToBounds = true 82 recordButton.setTitle("●", for: UIControl.State.normal) 83 recordButton.titleLabel?.font = UIFont.systemFont(ofSize: 50) 84 recordButton.layer.cornerRadius = 35.0 85 recordButton.layer.position = CGPoint(x: self.view.bounds.width/2, y: self.view.bounds.height-60) 86 recordButton.addTarget(self, action: #selector(ViewController.onClickRecordButton(sender:)), for: .touchUpInside) 87 self.view.addSubview(recordButton) 88 } 89 90 @objc func onClickRecordButton(sender: UIButton) { 91 if !isRecording { 92 startRecording() 93 isRecording = true 94 } else { 95 stopRecording() 96 isRecording = false 97 } 98 } 99 100 func setUpSettingButton() { 101 settingButton = UIButton(frame: CGRect(x: 0, y: 0, width: 30, height: 30)) 102 settingButton.setImage(settingButtonImage, for: .normal) 103 settingButton.layer.masksToBounds = true 104 settingButton.layer.position = CGPoint(x: self.view.bounds.width-40, y: self.view.bounds.height-50) 105 settingButton.addTarget(self, action: #selector(ViewController.onClickSettingButton), for: .touchUpInside) 106 self.view.addSubview(settingButton) 107 } 108 109 @objc func onClickSettingButton(sender: UIButton) { 110 self.performSegue(withIdentifier: "goSetting", sender: nil) 111 } 112 113 114}
回答1件
あなたの回答
tips
プレビュー