gpt4 book ai didi

ios - 如何将图像从解析到 UIImage 加载到 UITableViewCell Swift

转载 作者:搜寻专家 更新时间:2023-11-01 07:29:52 27 4
gpt4 key购买 nike

我无法通过解析加载图像。拇指称为“问题”没关系,但是当我尝试从解析加载图像时,发生错误并且应用程序崩溃

看看:

import UIKit
class TableViewController: PFQueryTableViewController {

// Initialise the PFQueryTable tableview

override init(style: UITableViewStyle, className: String!) {

super.init(style: style, className: className)

}

required init!(coder aDecoder: NSCoder) {

super.init(coder: aDecoder)

// Configure the PFQueryTableView

self.parseClassName = "Saude"

self.textKey = "Nome"

self.pullToRefreshEnabled = true

self.paginationEnabled = false

}

// Define the query that will provide the data for the table view

override func queryForTable() -> PFQuery {

let query = PFQuery(className: "Saude")

query.orderByAscending("Nome")

return query

}



override func viewDidLoad() {

super.viewDidLoad()



// Do any additional setup after loading the view.

}



override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell? {

var cell = tableView.dequeueReusableCellWithIdentifier("CustomCell") as! CustomTableViewCell!

if cell == nil

{

cell = CustomTableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "CustomCell")

}

if let nome = object?["Nome"] as? String

{

cell.customNome.text = nome

}

if let categoria = object?["Categoria"] as? String

{

cell.customCategoria.text = categoria

}

let initialThumbnail = UIImage(named: "question")

cell.customImage.image = initialThumbnail

if let thumbnail = object?["imageFile"] as? PFFile

{

cell.customImage.file = thumbnail

cell.customImage.loadInBackground()

}

return cell

}





// In a storyboard-based application, you will often want to do a little preparation before navigation

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

// Get the new view controller using [segue destinationViewController].

//*let detailScene = segue.destinationViewController as! DetailViewController

let detailScene : DetailViewController = segue.destinationViewControlleras! DetailViewController

// Pass the selected object to the destination view controller.

iflet indexPath = self.tableView.indexPathForSelectedRow {

let row = Int(indexPath.row)

detailScene.currentObject = (objects?[row] as! PFObject)

}

}

override func viewDidAppear(animated: Bool) {

// Refresh the table to ensure any data changes are displayed

tableView.reloadData()

}

}

错误:

2015-10-23 11:12:25.457 GuiaMogiNav[958:306603] -[UIImageView setFile:]: unrecognized selector sent to instance 0x176ce9a0

2015-10-23 11:12:25.459 GuiaMogiNav[958:306603] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView setFile:]: unrecognized selector sent to instance 0x176ce9a0'

*** First throw call stack:

(0x243bd85b 0x35d32dff 0x243c3025 0x243c0c7f 0x242f01a8 0xf13fc 0xf1810 0x189017 0x28830d63 0x28830e89 0x28820df5 0x2883546f 0x285db5af 0x284edcc3 0x27db5b05 0x27db1201 0x27db1091 0x27db05b1 0x27db0263 0x27da9a1f 0x24380091 0x2437e387 0x2437e7c5 0x242d10d9 0x242d0ecd 0x2d646af9 0x2855a2dd 0xe435c 0x36480873)

libc++abi.dylib: terminating with uncaught exception of type NSException

(lldb)

最佳答案

cell.customImage 是 PFImageView 吗?

UIImageView 没有属性文件,但是PFImageView 有,你应该用它来加载解析图像。

如果您使用 Storyboard,则需要在身份检查器中将 customImage 对象的类更改为 PFImageView。

关于ios - 如何将图像从解析到 UIImage 加载到 UITableViewCell Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33304729/

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