Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios TableView不再加载,但以前已加载_Ios_Swift_Uitableview_Tableview_Cell - Fatal编程技术网

Ios TableView不再加载,但以前已加载

Ios TableView不再加载,但以前已加载,ios,swift,uitableview,tableview,cell,Ios,Swift,Uitableview,Tableview,Cell,继续遇到此错误: 2017-04-28 11:58:06.873修复对象[97466:2668136]***在-[UITableViewRowData rectForRow:inSection:HeightCanbeguesed:],/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.6.21/UITableViewRowData.m:1846中断言失败 它可以工作,但是现在讨论行高度时崩溃了,但是我确实返回了

继续遇到此错误: 2017-04-28 11:58:06.873修复对象[97466:2668136]***在-[UITableViewRowData rectForRow:inSection:HeightCanbeguesed:],/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.6.21/UITableViewRowData.m:1846中断言失败

它可以工作,但是现在讨论行高度时崩溃了,但是我确实返回了与我相同的值。有人能看到这个问题吗?我有两个tableView,但一个叫做hireTableView,另一个叫做tableView

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    if(tableView == self.tableView){
        let cell  = self.tableView.dequeueReusableCell(withIdentifier: "Cell", for : indexPath) as! CustomCell


        let bgColorView = UIView()


        //bgColorView.backgroundColor = UIColor.clear.withAlphaComponent(0.15)
        //bgColorView.backgroundColor = UIColor.red

        cell.selectedBackgroundView = bgColorView



        if indexPath.row % 2 == 0
        {
            if(indexPath.row == 0){

                cell.profileTitleLabel.text = problems[(indexPath as NSIndexPath).row].getTitle()
                if(problems[(indexPath as NSIndexPath).row].status == 0){
                    cell.profileStatusLabel.textColor = UIColor.red
                }
                else{
                    cell.profileStatusLabel.textColor = UIColor(red: 28/255.0, green: 121/255.0, blue: 125/255.0, alpha: 1.0)
                }
                cell.profileStatusLabel.text = "\(problems[(indexPath as NSIndexPath).row].calculateSolved())"
                cell.profileMessageCountLabel.text = "\(problems[(indexPath as NSIndexPath).row].commentCount)"

                cell.profileProblemImage.image =  problems[(indexPath as NSIndexPath).row].getImage()

                cell.profileUpdateLabel.text = "Last Update: 13:01   25/01/2017"

                cell.backgroundColor = UIColor.white


            }
            else{

                cell.profileTitleLabel.text = problems[(indexPath as NSIndexPath).row - indexPath.row / 2].getTitle()
                if(problems[(indexPath as NSIndexPath).row - indexPath.row / 2].status == 0){
                    cell.profileStatusLabel.textColor = UIColor.red
                }
                else{
                    cell.profileStatusLabel.textColor = UIColor(red: 28/255.0, green: 121/255.0, blue: 125/255.0, alpha: 1.0)
                }
                cell.profileStatusLabel.text = "\(problems[(indexPath as NSIndexPath).row - indexPath.row / 2].calculateSolved())"
                cell.profileMessageCountLabel.text = "\(problems[(indexPath as NSIndexPath).row - indexPath.row / 2].commentCount)"
                cell.profileProblemImage.image = problems[(indexPath as NSIndexPath).row - indexPath.row / 2].getImage()

                cell.profileUpdateLabel.text = "Last Update: 13:01   25/01/2017"

                cell.backgroundColor = UIColor.white


            }
        }
        else{

            cell.backgroundColor = UIColor.clear

            cell.profileTitleLabel.text = ""
            cell.profileStatusLabel.text = ""
            cell.profileMessageCountLabel.text = ""

            cell.profileProblemImage.image = nil
            cell.profileUpdateLabel.text = ""
            cell.selectionStyle = .none


        }
        return cell

    }
    else{

        let cell  = self.tableView.dequeueReusableCell(withIdentifier: "Cell", for : indexPath) as! CustomCell
        cell.seperator.isHidden = true
        cell.bubble.isHidden = true

        let bgColorView = UIView()

        if indexPath.row % 2 == 0
        {
            if(indexPath.row == 0){

                cell.profileTitleLabel.text = ""
                cell.profileStatusLabel.text = ""
                cell.profileMessageCountLabel.text = ""

                cell.profileProblemImage.image = nil
                cell.profileUpdateLabel.text = ""

                cell.textLabel?.text = hires[(indexPath as NSIndexPath).row].title
                cell.detailTextLabel?.text = "\(hires[(indexPath as NSIndexPath).row].price)"


            }
            else{

                cell.profileTitleLabel.text = ""
                cell.profileStatusLabel.text = ""
                cell.profileMessageCountLabel.text = ""

                cell.profileProblemImage.image = nil
                cell.profileUpdateLabel.text = ""

                cell.textLabel?.text = hires[(indexPath as NSIndexPath).row - indexPath.row / 2].title
                cell.detailTextLabel?.text = "\(hires[(indexPath as NSIndexPath).row - indexPath.row / 2].price)"
            }
        }
        else{

            cell.backgroundColor = UIColor.clear

            cell.textLabel?.text = ""
            cell.detailTextLabel?.text = ""
            cell.selectionStyle = .none
            cell.profileTitleLabel.text = ""
            cell.profileStatusLabel.text = ""
            cell.profileMessageCountLabel.text = ""

            cell.profileProblemImage.image = nil
            cell.profileUpdateLabel.text = ""

        }


        return cell


    }




}





func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
{
    var height: CGFloat = 0

    if tableView == self.tableView {
        if indexPath.row % 2 == 0
        {
            height = 70 //cell height
        }
        else
        {
            height = 5 //space heigh
        }
    }

    if tableView == self.hireTableView {
        if indexPath.row % 2 == 0
        {
            height = 60 //cell height
        }
        else{
            height = 5 //space heigh
        }

    }


    return height
}

您需要对代码进行一些更改

  • 将您的线路替换为:

    让cell=self.tableView.dequeueReusableCell(带有标识符:“cell”)为!定制单元

  • 对两个单元格使用不同的标识符


  • 您需要对代码进行一些更改

  • 将您的线路替换为:

    让cell=self.tableView.dequeueReusableCell(带有标识符:“cell”)为!定制单元

  • 对两个单元格使用不同的标识符


  • 将您的行替换为:let cell=self.tableView.dequeueReusableCell(带标识符:“cell”)as!CustomCell或为两个Cell使用不同的标识符谢谢,替换行是修复它的方法!!干杯!酷!欢迎@Haydg8我可以添加这个作为我的答案吗?请添加!这是我的第一个问题,只是在谷歌上搜索如何为你的评论投票,并将其标记为答案哈哈!将您的行替换为:let cell=self.tableView.dequeueReusableCell(带标识符:“cell”)as!CustomCell或为两个Cell使用不同的标识符谢谢,替换行是修复它的方法!!干杯!酷!欢迎@Haydg8我可以添加这个作为我的答案吗?请添加!这是我的第一个问题,只是在谷歌上搜索如何为你的评论投票,并将其标记为答案哈哈!