0
我在我的应用程序中使用UITabBarController。让我们说调查表单与步骤,所以每个TabItem是步骤。在步骤3(选项卡3)有一个附件,它是使用UIImagePickerController喜欢这个。使用Alamofire上传图像通过使用UIImagePickerController
import UIKit
class AttachmentViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate{
@IBOutlet weak var photoCollectionView: UICollectionView!
var photo = [Photo]()
//..... Collection View Delegate and Datasource for displaying images
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
var newImage: UIImage
if let possibleImage = info["UIImagePickerControllerEditedImage"] as? UIImage {
newImage = possibleImage
} else if let possibleImage = info["UIImagePickerControllerOriginalImage"] as? UIImage {
newImage = possibleImage
} else {
return
}
let imageName = NSUUID().UUIDString
let imagePath = getDocumentsDirectory().stringByAppendingPathComponent(imageName)
if let jpegData = UIImageJPEGRepresentation(newImage, 80) {
jpegData.writeToFile(imagePath, atomically: true)
}
let finalPhoto = Photo(image: imageName)
photo.append(finalPhoto)
photoCollectionView.reloadData()
dismissViewControllerAnimated(true, completion: nil)
}
问题是我不知道如何上传与swift.I使用Alamofire现在可以得到图像字节的图像,我只是不知道如何使用alamofire把它上传。