Ios 故事板不';t包含标识符为';goToC&x27;
我想通过单击按钮进入CameraViewController,然后拍摄二维码的照片。 我一直在犯这个错误 谢谢大家的帮助 我在故事板上给了每个ViewController它的类型Ios 故事板不';t包含标识符为';goToC&x27;,ios,swift,uitableview,storyboard,segue,Ios,Swift,Uitableview,Storyboard,Segue,我想通过单击按钮进入CameraViewController,然后拍摄二维码的照片。 我一直在犯这个错误 谢谢大家的帮助 我在故事板上给了每个ViewController它的类型 import UIKit class movieListViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { @IBOutlet weak var movieTableView: UITableView!
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)
}
}
导入UIKit
类movieListViewController:UIViewController、UITableViewDelegate、UITableViewDataSource{
@IBVAR movieTableView:UITableView!
var movie:[movie]=[movie]()
var currentMovies:[电影]=[电影]()
变量计数器=0
重写func viewDidLoad(){
super.viewDidLoad()
movie=Helpers.downloadJson()
self.movieTableView.reloadData()
排序()
}
func排序(){
movie.sort(按:{$0.releaseYear<$1.releaseYear})
movieTableView.reloadData()
}
func tableView(tableView:UITableView,numberofrowsinssection:Int)->Int{
return.count
}
func tableView(tableView:UITableView,cellForRowAt indexath:indexPath)->UITableViewCell{
让cell=tableView.dequeueReusableCell(标识符为“MovieCell”)作为!MovieCell
createCell(电影:电影[indexPath.row])
返回单元
}
func tableView(tableView:UITableView,didSelectRowAt indexPath:indexPath){
让selectedMovie=movie[indexPath.row]
性能检查(标识符为“goToDetail”,发件人:selectedMovie)
}
覆盖功能准备(对于segue:UIStoryboardSegue,发送方:有吗?){
设nextVC=segue.destination为!DetailViewController
nextVC.movie=发件人为!movie
}
@IBAction func addTapped(uu发送方:任何){
让故事板:UIStoryboard=UIStoryboard(名称:“Main”,bundle:nil)
让nextView=storyBoard.InstanceDeviceController(标识符为“goToC”)作为!CameraViewController
self.present(nextView,动画:true,完成:nil)
}
}
摄像机控制器:
导入UIKit
进口AVF基金会
类CameraViewController:UIViewController、AVCaptureMataOutputObject Legate{
var captureSession:AVCaptureSession?
var videoPreviewLayer:AVCaptureVideoPreviewLayer?
var qrCodeFrameView:UIView?
重写func viewDidLoad(){
super.viewDidLoad()
让captureDevice=AVCaptureDevice.defaultDevice(带MediaType:AVMediaTypeVideo)
做{
让输入=尝试AVCaptureDeviceInput(设备:captureDevice)
captureSession=AVCaptureSession()
captureSession?.addInput(输入)
}抓住{
打印(错误)
返回
}
让captureMataOutput=avcaptureMataDataOutput()
captureSession?.addOutput(CaptureMataOutput)
CaptureMataOutput.setMetadataObjectsDelegate(self,队列:DispatchQueue.main)
CaptureMataOutput.metadataObjectTypes=[AVMetadataObjectTypeQRCode]
videoPreviewLayer=AVCaptureVideoPreviewLayer(会话:captureSession)
videoPreviewLayer?.videoGravity=AVLayerVideoGravityResizeAspectFill
videoPreviewLayer?.frame=view.layer.bounds
view.layer.addSublayer(videoPreviewLayer!)
captureSession?.startRunning()
qrCodeFrameView=UIView()
如果让newFrame=qrCodeFrameView{
newFrame.layer.borderColor=UIColor.green.cgColor
newFrame.layer.borderWidth=2
view.addSubview(新建框架)
view.bringSubview(toFront:newFrame)
}
}
}
详细视图控制器
导入UIKit
类DetailViewController:UIViewController{
@IBVAR电影图像:UIImageView!
@IBOutlet弱var标题BL:UILabel!
@IBL弱var释放年鉴:UILabel!
@IBL弱变率LBL:UILabel!
var movie:movie=movie()
重写func viewDidLoad(){
super.viewDidLoad()
titleLbl.text=movie.title
ratingLbl.text=“评级:\(movie.Rating)⭐️"
releaseYearLbl.text=“发布年份:\(movie.releaseYear)”
movieImage.layer.cornerRadius=5.0
movieImage.clipstobunds=true
movieImage.sd_setImage(带:URL(字符串:movie.image))
}
@iAction func backToList(\发送方:任意){
self.disclose(动画:true,完成:nil)
}
}
Xcode 8.2.1
我以为CameraViewController
在你的Main
情节提要中
在Main
Storyboard中,首先选择相应的viewController
顶部的黄色按钮,然后转到identity inspector->identity->Storyboard ID
为这种情况输入视图控制器标识符goToC
Xcode 8.2.1 我以为
CameraViewController
在你的Main
情节提要中
在Main
Storyboard中,首先选择相应的viewController
顶部的黄色按钮,然后转到identity inspector->identity->Storyboard ID
为这种情况输入视图控制器标识符goToC
您一定是错误地设置了segue…检查segue是否正确,并且目标视图控制器是否与您希望的相同,是否可能重复您是否有任何其他segue从movielist view controller启动?具体检查segue从
movieListViewController
到DetailViewControlroller
。我猜你是错误地在movieListViewController
到CamerViewController
之间设置了segue。你一定是设置了错误的segue…检查segue是否正确,目标视图控制器是否与你想要的相同,是否可能重复。你是否有其他从mov启动的segueielist视图控制