@sportredwhite

Как сделать выпадающий список?

Подскажите плз, какой нужно использовать элемент, чтобы сделать выпадающей список, как на картинке?

5b5ec11e7c8f9552451330.png
  • Вопрос задан
  • 1836 просмотров
Решения вопроса 2
SnapSh0t
@SnapSh0t
iOS-Developer
Я создавал 2 динамические ячейки в TableView и на нажатие добавлял кастомную ячейку ниже.
TabelView
5b5efcca68b1c646755063.png5b5efd0a45f87893330570.png
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        if (destinationData?[indexPath.row]) != nil {
            if(indexPath.row + 1 >= (destinationData?.count)!) {
                expandCell(tableView: tableView, index: indexPath.row)
            }
            else {
                if(destinationData?[indexPath.row+1] != nil) {
                    expandCell(tableView: tableView, index: indexPath.row)
                    // Close Cell (remove ExpansionCells)
                } else {
                    contractCell(tableView: tableView, index: indexPath.row)
                }
            }
        }
    }
    
    /*  Expand cell at given index  */
    private func expandCell(tableView: UITableView, index: Int) {
        if let infoMain = destinationData?[index]?.infoMain {
            var indexesToInsert = [IndexPath]()
            for i in 1...infoMain.count {
                destinationData?.insert(nil, at: index + 1)
                indexesToInsert.append(IndexPath(row: index + i, section: 0))
            }
            tableView.insertRows(at: indexesToInsert , with: .left)
            tableView.scrollToRow(at: IndexPath(row: index + 1, section: 0), at: .bottom, animated: true)
        }
    }
    
    /*  Contract cell at given index    */
    private func contractCell(tableView: UITableView, index: Int) {
        if let infoMain = destinationData?[index]?.infoMain {
            var indexesToDelete = [IndexPath]()
            for i in 1...infoMain.count {
                destinationData?.remove(at: index + 1)
                indexesToDelete.append(IndexPath(row: index + i, section: 0))
            }
            tableView.deleteRows(at: indexesToDelete, with: .left)
        }
    }
Ответ написан
Комментировать
NSA-bot
@NSA-bot
Насколько я знаю, стандартного элемента нет.
Гуглите (или яндексите :) ) "swift dropdown list" или "swift dropdown menu"
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы