Show two different custom cells in same uitableview - swift firebase

前端 未结 6 1547
心在旅途
心在旅途 2021-02-06 20:15

I am currently having a problem with displaying two different types of custom cells on the same uitableview.

What I have managed so far, is receiving the \"updates\" to

6条回答
  •  梦毁少年i
    2021-02-06 20:38

    You should return total number of rows in your numberOfRowsInSection method. so you can return summation of your both array's count something like,

     return updates.count + updatesTask.count
    

    now in your cellForRowAtIndexPath method you can differentiate your cell something like,

        let cell:updateTableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! updateTableViewCell
        let cellTask:tasksTableViewCell = tableView.dequeueReusableCellWithIdentifier("TaskCell", forIndexPath: indexPath) as! tasksTableViewCell
    
    
    
        if indexPath.row % 2 == 1 {
    
            //your second cell - configure and return
            return cellTask
        }
        else
        {
    
        //your first cell - configured and return
            return cell
        }
    

提交回复
热议问题