Access different views inside of a UITableViewCell by tag in Swift

i think the Problem is the Tag 0. All Views are on default value 0. So try another tag value.


Just faced the same issue. The solution was to change tag to 10 and 20. I used 1 and 2 before. Is anybody aware of a range of tags that is used by the system?

So my 'cellForRowAtIndexPath' for a table with an image and a label per row looks like this now:

internal func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    if let cell = tableView.dequeueReusableCellWithIdentifier("cellIdentifier") as? UITableViewCell {
        (cell.contentView.viewWithTag(10) as UIImageView).image = IMAGES[indexPath.row]
        (cell.contentView.viewWithTag(20) as UILabel).text = LABELS[indexPath.row]

        return cell
    } else {
        NSLog("Prototype did not work")
        return UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "errorIdentifier")
    }
}