PFFile到UIImage

时间:2016-01-06 22:15:08

标签: ios parse-platform uiimage

您好我知道已经有关于此主题的问题,但我无法让我的代码工作。我使用swift 2进入xcode 7.2 beta。

我想让Image成为我按钮的背景:

self.Button1.setBackgroundImage(UIImage(named: [Here the image of in the PFFFile] , forState: UIControlState.Normal)

那么有人可以解释一下如何将PFFile转换为可用于按钮背景的UIImage吗?

 func Call(){   let countQuery = PFQuery(className: "My_Classname")
    countQuery.countObjectsInBackgroundWithBlock { (count: Int32, error: NSError?) -> Void in
        if (error == nil) { let randomNumber = Int(arc4random_uniform(UInt32(count)))
            let query = PFQuery(className: "My_Classname")
            query.skip = randomNumber; query.limit = 1
            query.findObjectsInBackgroundWithBlock { (objects: [PFObject]?, error: NSError?) -> Void in
                 if (error == nil) {
let object: AnyObject = objects![0]
self.image1 = object ["image1"] as! PFFile!
self.image2 = object ["image2"] as! PFFile!
self.image3 = object ["image3"] as! PFFile!
self.image4 = object ["image4"] as! PFFile!

我希望有人可以帮助我! stackoverflow上的大多数代码都在xcode 6 swift中。

0 个答案:

没有答案