>

버튼을 클릭하여 CameraViewController에 들어간 다음 qr 코드 사진을 찍고 싶습니다. 이 오류가 계속 발생합니다 도와 주셔서 감사합니다 스토리 보드에 모든 ViewController 유형을 입력했습니다.

import UIKit
class movieListViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
    @IBOutlet weak var movieTableView: UITableView!

    var movie:[Movie] = [Movie]()
    var currentMovies:[Movie] = [Movie]()
    var counter = 0
    override func viewDidLoad() {
        super.viewDidLoad()
        movie = Helpers.downloadJson()
        self.movieTableView.reloadData()
        sort()
    }
    func sort() {
        movie.sort(by: { $0.releaseYear < $1.releaseYear })
        movieTableView.reloadData()
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return movie.count
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "MovieCell") as! MovieCell
        cell.createCell(movie: movie[indexPath.row])
        return cell
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let selectedMovie = movie[indexPath.row]
        performSegue(withIdentifier: "goToDetail", sender: selectedMovie)
    }
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        let nextVC = segue.destination as! DetailViewController
        nextVC.movie = sender as! Movie
    }
    @IBAction func addTapped(_ sender: Any) {
        let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
        let nextView = storyBoard.instantiateViewController(withIdentifier: "goToC") as! CameraViewController
        self.present(nextView, animated: true, completion: nil)
    }
}
    CameraViewController:

    import UIKit
    import AVFoundation
    class CameraViewController: UIViewController, AVCaptureMetadataOutputObjectsDelegate {
        var captureSession: AVCaptureSession?
        var videoPreviewLayer: AVCaptureVideoPreviewLayer?
        var qrCodeFrameView: UIView?
        override func viewDidLoad() {
            super.viewDidLoad()
            let captureDevice = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeVideo)
            do {
                let input = try AVCaptureDeviceInput(device: captureDevice)
                captureSession = AVCaptureSession()
                captureSession?.addInput(input)
            } catch {
                print(error)
                return
            }
            let captureMetaDataOutput = AVCaptureMetadataOutput()
            captureSession?.addOutput(captureMetaDataOutput)
            captureMetaDataOutput.setMetadataObjectsDelegate(self, queue: DispatchQueue.main)
            captureMetaDataOutput.metadataObjectTypes = [AVMetadataObjectTypeQRCode]
            videoPreviewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
            videoPreviewLayer?.videoGravity = AVLayerVideoGravityResizeAspectFill
            videoPreviewLayer?.frame = view.layer.bounds
            view.layer.addSublayer(videoPreviewLayer!)
            captureSession?.startRunning()
            qrCodeFrameView = UIView()
            if let newFrame = qrCodeFrameView {
                newFrame.layer.borderColor = UIColor.green.cgColor
                newFrame.layer.borderWidth = 2
                view.addSubview(newFrame)
                view.bringSubview(toFront: newFrame)
            }
        }
    }


    DetailViewController
    import UIKit
    class DetailViewController: UIViewController {
        @IBOutlet weak var movieImage: UIImageView!
        @IBOutlet weak var titleLbl: UILabel!
        @IBOutlet weak var releaseYearLbl: UILabel!
        @IBOutlet weak var ratingLbl: UILabel!
        var movie: Movie = Movie()
        override func viewDidLoad() {
            super.viewDidLoad()
            titleLbl.text = movie.title
            ratingLbl.text = "Rating: \(movie.rating) ⭐️"
            releaseYearLbl.text = "Release Year: \(movie.releaseYear)"
            movieImage.layer.cornerRadius = 5.0
            movieImage.clipsToBounds = true
            movieImage.sd_setImage(with: URL(string: movie.image))
        }
        @IBAction func backToList(_ sender: Any) {
            self.dismiss(animated: true, completion: nil)
        }

    }

  • 답변 # 1

    Xcode 8.2.1

    나는 CameraViewController 생각  당신의 Main 에  스토리 보드.

    Main 에서  스토리 보드 먼저 적절한 viewController 의 노란색 버튼 상단을 선택  고토 와이즈 비즈  이 경우에 귀하의 뷰 컨트롤러 식별자를 입력하십시오

    identity inspector -> identity -> Storyboard ID

관련 자료

  • 이전 bash - Mac에서 실행할 때 일치하는` " '오류를 찾는 동안 예기치 않은 EOF가 발생했습니다
  • 다음 running R in batch mode - 배치 모드에서 r 실행 - 화면에 인쇄 하시겠습니까?