问题描述
我想知道是否可以上传10张图片进行解析,然后能够在显示用户用户名的TableView中显示它们。
I am wondering if its possible to upload 10 images to parse, and then be able to display them in TableView displaying the users username.
所以基本上当我下载他们从解析我猜测需要有一些东西将这些图像链接到同一个用户或1个单独的帖子...
So basically when I download them from parse I'm guessing there needs to be something linking those images to the same user or that 1 individual post...
不确定这是否可行,但是我读了这两个问题,我认为你可以!
Not sure if this is possible, but I read these two questions and I think you can!
如果有人理解我的意思,我会很乐意帮助你!
If anyone understands what I mean, I would love your help!
祝你好运。
推荐答案
如上所述,您可以将图像数组添加到列i在您的User类中,下面的代码允许您创建一个新用户,并将采用图像数组并根据需要创建尽可能多的列。它们的标题是imageArray0,imageArray1等。下次使用图片创建用户时,它们会自动添加到Parse中的相应列中。
As discussed, you can add the array of images to a column in your User class, the code below allows you to create a new user and will take an image array and create as many columns as necessary. They will be titled "imageArray0", "imageArray1" and so on. The next time you create a user with images they will automatically be added to the corresponding columns in Parse.
更新
已添加图片转换:
let user = PFUser()
user.username = chosenUsername
for i in imageArray.indices {
let imageData = imageArray[i].mediumQualityJPEGNSData
let imageFile = PFFile(name: "image.JPEG", data: imageData)
user["imageArray\(i)"] = imageFile
}
user.signUpInBackgroundWithBlock({
success, error in
if error == nil {
} else {
}
})
我还使用此扩展程序轻松地将图像转换为各种质量:
I also use this extension to easily convert images to various qualities:
extension UIImage {
var uncompressedPNGData: NSData { return UIImagePNGRepresentation(self)! }
var highestQualityJPEGNSData: NSData { return UIImageJPEGRepresentation(self, 1.0)! }
var highQualityJPEGNSData: NSData { return UIImageJPEGRepresentation(self, 0.75)! }
var mediumQualityJPEGNSData: NSData { return UIImageJPEGRepresentation(self, 0.5)! }
var lowQualityJPEGNSData: NSData { return UIImageJPEGRepresentation(self, 0.25)! }
var lowestQualityJPEGNSData:NSData { return
UIImageJPEGRepresentation(self, 0.0)! }
}
这篇关于将多个图像上传到Parse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!