【发布时间】:2014-12-03 21:18:34
【问题描述】:
我最近在一个 Objective-C 项目中添加了一些 swift 代码,但我遇到了一些我无法解决的奇怪问题。
我正在使用我自定义的搜索栏(来自 Ray 教程)。在cellForRowAtIndexPath 方法中,我可以自定义我的单元格标签,一切正常。唯一的问题是我不能根据 if (BOOL) 条件隐藏一些 imageViews。我的 swift 代码一定有问题,因为我可以使用相同的 if (BOOL) 条件将这些图像隐藏在 Objective-C 文件中。
以防万一我发布我的代码,如果有人可以帮助我。
在 SearchVC 中(swift)
class aCell : UITableViewCell {
@IBOutlet weak var some label...
@IBOutlet weak var imageFacturation: UIImageView!
@IBOutlet weak var imageMail: UIImageView!
}
class PatientSearchViewController : ...
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCellWithIdentifier("CellSwift") as aCell // aCell is a class defined inside the file where I attach the label and imageView properties
var person : ClassObject
if tableView == self.searchDisplayController!.searchResultsTableView {
person = filteredObjects[indexPath.row]
} else {
person = objects[indexPath.row]
}
// Configure the cell
cell.labelLastname.text = person.lastname
cell.labelFirstname.text = person.firstname
if person.hasMailSent == false {
cell.imageMail.hidden == true // --> does not work in swift code but is Hidden in objective-C with the setHidden:true
}
if person.hasFacturation == false {
cell.imageFacturation.hidden == true // --> does not work in swift code but is Hidden in objective-C with the setHidden:true
}
return cell
}
有人有想法吗?
【问题讨论】:
标签: ios uitableview swift uiimageview hidden