Tri*_*ton 0 hidden uitableview uiimageview ios swift
我最近在Objective-C项目中添加了一些快速代码,我面临着一些我无法解决的奇怪问题.
我正在使用我定制的Searchbar(来自Ray教程).在cellForRowAtIndexPath方法中,我可以自定义我的单元格标签,一切正常.唯一的问题是我无法根据if(BOOL)条件隐藏一些imageViews.我的swift代码肯定有问题,因为我可以使用相同的if(BOOL)条件在Objective-C文件中隐藏这些图像.
万一我发布我的代码,如果有人可以帮助我.
在SearchVC(快速)
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
}
Run Code Online (Sandbox Code Playgroud)
有没有人有想法?
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
}
Run Code Online (Sandbox Code Playgroud)
在这行中cell.imageMail.hidden == true你基本上是比较而不是分配.它应该只是cell.imageMail.hidden = true你想要分配值.
| 归档时间: |
|
| 查看次数: |
5099 次 |
| 最近记录: |