iOS swift imageView не може да бъде скрит в TableViewCell

Наскоро добавих някакъв бърз код в обект на object-C проект и се сблъсквам с нещо странно, което не мога да разбера.

Използвам лентата за търсене (от урока на Ray), която персонализирах. В метода cellForRowAtIndexPath мога да персонализирам етикетите на клетките си и всичко работи добре. Единственото нещо е, че не мога да скрия някои изображения Views според условията if (BOOL). Нещо трябва да не е наред с моя swift код, тъй като мога да скрия тези изображения в Objective-C файлове със същите условия if (BOOL).

За всеки случай публикувам кода си, ако някой може да ми помогне.

В 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
}

Някой има ли идея?


person Trichophyton    schedule 03.12.2014    source източник


Отговори (1)


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
}

В ред cell.imageMail.hidden == true вие основно сравнявате, а не присвоявате. Трябва просто да бъде cell.imageMail.hidden = true, ако искате да присвоите стойността.

person Vig    schedule 03.12.2014
comment
Аха, такава ужасна начинаеща грешка... толкова глупаво от моя страна. Благодаря много :-) - person Trichophyton; 04.12.2014