UITableViewCell中的ImageView将不会显示

时间:2015-07-11 17:24:56

标签: ios iphone swift storyboard

我在我的故事板上将一个ImageView放在UITableViewCell中,但是在运行时它没有显示在我的模拟器上。我该如何解决这个问题?

我的故事板:

Image of my storyboard 我的故事板的对象概述:

enter image description here 填充单元格的Swift代码:

func tableView(gamesListTableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    var cell = gamesListTableView.dequeueReusableCellWithIdentifier("Game", forIndexPath: indexPath) as! UITableViewCell
    if (indexPath.row < GamesList.count) {
        cell.detailTextLabel?.text = GamesList[indexPath.row]["game_guid"].string!;
        cell.textLabel?.text = GamesList[indexPath.row]["opponent_name"].string!;
        if (GamesList[indexPath.row]["self_turn"] == false) {
            cell.textLabel?.textColor = UIColor.greenColor();
        } else if (GamesList[indexPath.row]["game_idle_time"] <= 60) {
            cell.textLabel?.textColor = UIColor.yellowColor();
        } else {
            cell.textLabel?.textColor = UIColor.redColor();
        }
    } else {
        cell.detailTextLabel?.text = InvitesList[indexPath.row - GamesList.count]["invite_guid"].string!;
        cell.textLabel?.text = InvitesList[indexPath.row - GamesList.count]["invite_text"].string!;
        cell.textLabel?.textColor = UIColor.blueColor();
    }
    return cell
}

在运行时的样子:

enter image description here

1 个答案:

答案 0 :(得分:1)

您应该暂停执行并在Xcode中查看视图层次结构。检查它在运行时的帧大小,看看是否有东西与它重叠或B.(如果你的约束是错误的。)

相关问题