gpt4 book ai didi

ios - 使用未解析的标识符 'CameraViewController'

转载 作者:行者123 更新时间:2023-11-30 13:28:20 25 4
gpt4 key购买 nike

我收到此错误,如何修复它?

https://www.dropbox.com/s/ipgedtenxjzsm7q/Captura%20de%20pantalla%202016-04-26%2020.07.52.png?dl=0

Use of unresolved identifier 'CameraViewController'

我正在使用https://cocoapods.org/pods/ALCameraViewController

代码:

  import UIKit

class pantalla6: UIViewController, UIImagePickerControllerDelegate , UINavigationControllerDelegate, UICollectionViewDataSource, UICollectionViewDelegate {

// "Mes 1", "Mes 2", "Mes 3", "Mes 4", "Mes 5", "Mes 6", "Mes 7", "Mes 8", "Mes 9", "Mes 10", "Mes 11", "Mes 12"

var tableData: [String] = []
var tableImages: [UIImage] = []
var tableControl: Int = 0
var guardaImagen: UIImage?
var indexPathSelected : Int = 0

//NSUSERDEFAULTS // guardar estado
var objetoNsDefault = NSUserDefaults.standardUserDefaults()
var stringsarraydeimagenes:[String]?
var key = "keySave" //Se guarda el nombre de las imagenes en esta key

//FIN NSUSERDEFAULTS


//var CeldaSwipeada: Int = 0




override func viewDidLoad() {
super.viewDidLoad()

let croppingEnabled = true
let cameraViewController = CameraViewController(croppingEnabled: croppingEnabled) { image in
// Do something with your image here.
// If cropping is enabled this image will be the cropped version
}

presentViewController(cameraViewController, animated: true, completion: nil)

//USAR SWYPE START


//self.collectionview.cellForItemAtIndexPath(indexPathSelected).addGestureRecognizer(swipeRight)


//USAR SWYPE FIN

collectionview.delegate = self
imagePicker.delegate = self /// estableces que el delegado va estar en este viewcontroller


//RECUPERAR IMAGENES
//tableImages = NSUserDefaults.standardUserDefaults().arrayForKey("ImagenesGuardadas")

/* LO QUE YO HABIA PUESTO
if let testArray : AnyObject? = objetoNsDefault.objectForKey(key) {
var readArray : [NSString] = testArray! as! [NSString] //falta saber donde se guardar las imagenes tableImages es del tipo UIimages
}
*/

//LO QUE TU HABÍAS PUESTO
/*
let placesData = NSUserDefaults.standardUserDefaults().objectForKey("ImagenesGuardadas") as? NSData


tableImages = (NSKeyedUnarchiver.unarchiveObjectWithData(placesData!) as? [UIImage])!
*/




// Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {return UIInterfaceOrientation.Landscape.rawValue}



func guardardatos(){

/*LO QUE PUSISTE
let placesData = NSKeyedArchiver.archivedDataWithRootObject(tableImages)
NSUserDefaults.standardUserDefaults().setObject(placesData, forKey: "ImagenesGuardadas")

*/

//save
let defaults = NSUserDefaults.standardUserDefaults()
defaults.setObject(stringsarraydeimagenes, forKey: key)
defaults.synchronize()

/*
NSUserDefaults.standardUserDefaults().setObject(tableImages, forKey: "ImagenesGuardadas")

NSUserDefaults.standardUserDefaults().synchronize()
*/
print("dato guardado")
}

func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return tableData.count
}

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell: colvwCell = collectionview.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! colvwCell
cell.lblCell.text = tableData[indexPath.row]
cell.imgCell.image = tableImages[indexPath.row]


/*quitando esto se ve mejor*/

cell.basurita.hidden = false
cell.imgCell.contentMode = UIViewContentMode.ScaleAspectFit

cell.basurita?.layer.setValue(indexPath.row, forKey: "index")


// cell.basurita?.addTarget(self, action: "deleteUser:", forControlEvents: UIControlEvents.TouchUpInside)


//let action = #selector(self.deleteUser)

//cell.basurita.addTarget(self, action: action, forControlEvents: .TouchUpInside)

cell.basurita?.addTarget(self, action:#selector(pantalla6.deleteUser(_:)),
forControlEvents: UIControlEvents.TouchUpInside)

/*quitando esto se ve mejor*/

// Remove the button from the first cell
/*if (indexPath.row == 0){
let close : UIButton = cell.viewWithTag(11) as! UIButton
close.hidden = true
}
*/

return cell
}


func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
print("Cell \(indexPath.row) selected")
indexPathSelected = indexPath.row


//pantalla8fotoViewController().newImage = tableImages[indexPathSelected]
let loginPageView = self.storyboard?.instantiateViewControllerWithIdentifier("FotosID") as! pantalla8fotoViewController
loginPageView.newImage = tableImages[indexPathSelected]
self.presentViewController(loginPageView, animated: true, completion: nil)


//loginPageView.newImage = tableImages[indexPathSelected]
print("pasado")
print(indexPathSelected)
// print(loginPageView.newImage)
}

@IBOutlet weak var collectionview: UICollectionView!

@IBOutlet weak var picture: UIImageView! /// defines el UIImageView

let imagePicker = UIImagePickerController() /// defines el image Picker




@IBAction func openLibrary(sender: AnyObject) { ///accion del boton Library

imagePicker.allowsEditing = false
imagePicker.sourceType = .PhotoLibrary

presentViewController(imagePicker, animated:true, completion: nil)

}

@IBAction func openCamera(sender: AnyObject) { ///accion del boton Camara



imagePicker.allowsEditing = false
imagePicker.sourceType = .Camera



presentViewController(imagePicker, animated:true, completion: nil)

}

//Mark: delegates //// delegado del imagePicker controller que establece que una imagen fue escogida ya sea de la camara o del carrete

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {


if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
//picture.contentMode = .ScaleAspectFit
//picture.image = pickedImage



tableImages.append(pickedImage)
tableImages.insert(pickedImage, atIndex: tableControl)

tableData.append("Mes " + "\(tableControl + 1)")
//tableImages.insert(pickedImage, atIndex: tableControl)
//tableImages[tableControl] = pickedImage
//tableData[tableControl] = "Mes " + "\(tableControl + 1)"

guardaImagen = pickedImage

if (picker.sourceType == UIImagePickerControllerSourceType.Camera)

{
UIImageWriteToSavedPhotosAlbum(guardaImagen!, nil, nil, nil);
}
// arraynsuserdefault = tableImages


collectionview.reloadData()
tableControl += 1
}
//NO ESTA EN EL TUTORIAL

dismissViewControllerAnimated(true, completion: nil)
}


// metodo tambien del delegado que detecta si se presiono cancel en el picker

func imagePickerControllerDidCancel(picker: UIImagePickerController) {
dismissViewControllerAnimated(true, completion: nil)
}

func deleteUser(sender:UIButton) {

let i : Int = (sender.layer.valueForKey("index")) as! Int
//tableData.removeAtIndex(i)
// tableData = nil
let image : UIImage = UIImage(named:"cup.png")!
tableImages[i] = image
//tableControl--
collectionview.reloadData()

}

func respondToSwipeGesture(gesture: UIGestureRecognizer) {
if let swipeGesture = gesture as? UISwipeGestureRecognizer {


}
}

@IBAction func cancelar(sender: AnyObject) {
self.dismissViewControllerAnimated(true, completion: nil)

}


@IBAction func BorrarFotos(sender: AnyObject) {
tableImages.removeAll()
tableData.removeAll()
tableControl = 0
collectionview.reloadData()

}

}

最佳答案

可能有许多问题导致此问题。

  1. 您没有在调用 ALCameraViewController 对象的文件顶部导入 ALCameraViewController。 README.md并没有告诉您这样做,但为了让您的项目识别它,这是必要的。

  2. 您没有 Xcode 7.3 和 Swift 2.2。某些语法与 Swift 2.1 到 2.2 不同。因此,请确保您的操作系统、Xcode 程序和 Swift 语言已更新。

关于ios - 使用未解析的标识符 'CameraViewController',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36872744/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com