私はカメラアプリを作った。ポートレートモードでは、次のようになります。 風景モードのカメラがフルスクリーンでない
横長モードではフルスクリーンではないので、何故その理由が考えられますか?ここで
takePhoto機能です:あなたは、デバイスを回転させたとき
@IBAction func takePhoto(sender: AnyObject) {
var imageViewBackground: UIImageView!
self.fullScreenView.hidden = false
self.recordButton.enabled = false
self.takephoto.enabled = false
self.recordButton.hidden = true
self.takephoto.hidden = true
session.startRunning()
// add the AVCaptureVideoPreviewLayer to the view and sets the view in fullscreen
fullScreenView.frame = view.bounds
fullScreenView.layer.addSublayer(videoPreviewLayer)
// add action to fullScreenView
gestureFullScreenView = UITapGestureRecognizer(target: self, action: #selector(ViewController.takePhoto(_:)))
self.fullScreenView.addGestureRecognizer(gestureFullScreenView)
// add action to myView
gestureView = UITapGestureRecognizer(target: self, action: #selector(ViewController.setFrontpage(_:)))
self.view.addGestureRecognizer(gestureView)
if (preview == true) {
if let videoConnection = stillImageOutput!.connectionWithMediaType(AVMediaTypeVideo) {
// code for photo capture goes here...
stillImageOutput?.captureStillImageAsynchronouslyFromConnection(videoConnection, completionHandler: { (sampleBuffer, error) -> Void in
// process the image data (sampleBuffer) here to get an image file we can put in our view
if (sampleBuffer != nil) {
let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(sampleBuffer)
let dataProvider = CGDataProviderCreateWithCFData(imageData)
let cgImageRef = CGImageCreateWithJPEGDataProvider(dataProvider, nil, true, CGColorRenderingIntent.RenderingIntentDefault)
let image = UIImage(CGImage: cgImageRef!, scale: 1.0, orientation: UIImageOrientation.Right)
self.fullScreenView.hidden = true
self.fullScreenView.gestureRecognizers?.forEach(self.fullScreenView.removeGestureRecognizer)
self.session.stopRunning()
// save image to the library
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
imageViewBackground = UIImageView(frame: CGRectMake(0, 0, self.width, self.height))
imageViewBackground.image = image
imageViewBackground.tag = self.key
self.view.addSubview(imageViewBackground)
}
})
}
}
else {
preview = true
}
}
plsは関連するコードで質問を更新します。どうやってカメラを始めるのですか? –
takephotoメソッド – mafioso