Нужно установить новые ограничения для конкретного indexPath.row - PullRequest
0 голосов
/ 05 июня 2018

В раскадровке я установил ограничение ограничений вида таблицы влево и вправо на ноль.

Но в зависимости от моего indexPath.row мне нужно установить новые ограничения (inset & width).Я пробовал это без успеха.

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

        case .mycase:
            let cell = tableView.dequeueReusableCell(withIdentifier: "NoBrandDeviceFoundTableViewCell", for: indexPath) as! NoBrandDeviceFoundTableViewCell
            tableView.isScrollEnabled = false

        var frame = tableView.frame
        frame.size.width = 343
        cell.frame = frame
        tableView.contentInset = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)

            return cell
        }
    }

Ответы [ 2 ]

0 голосов
/ 05 июня 2018
you need to take cell leading constanint -  nslcLeadingCell
you need to take cell trailing constatint - nslcTrailningCell

based on indexpathrow contion match you need make condition

if indexpath.row == 5

cell.nslcLeadingCell.constant =  10
cell.nslcTrailningCell.constanct = 15
0 голосов
/ 05 июня 2018

Рамка ячейки не будет изменена, она установлена ​​равной ширине таблицы, вы можете перехватить ведущие / левые и конечные / правые ограничения элементов, которые вы хотите сместить, и изменить значение их константы в соответствии сэтот indexPath в cellForRowAt

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

   let cell = tableView.dequeueReusableCell(withIdentifier: "NoBrandDeviceFoundTableViewCell", for: indexPath) as! NoBrandDeviceFoundTableViewCell

    if indexPath.row == <#someValue#> {

       cell.lblLeadingCon.constant = <#someValue#>
    }
    else {

       cell.lblLeadingCon.constant = 0
    }

    return cell

}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...