настроить высоту tableViewCell

Итак, я пытаюсь установить 3 разных ячейки tableView в UITableView с разной высотой для каждой ячейки. Мне интересно, как мне вернуть 3 разные ячейки, каждая со своей собственной высотой?

Спасибо за подсказки или помощь!

// MARK: - Table view data source

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {

    return 3
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    if(section == 0) {
        return 1
    }
    if(section == 1) {
        return 1
    }
    else {
        return 10
    }

}


override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    switch indexPath.section{
    case 0:
        let myProfile = tableView.dequeueReusableCellWithIdentifier("ProfileHeaderCell") as! VideoTableViewCell



        return myProfile

    case 1:
        let myInfo = tableView.dequeueReusableCellWithIdentifier("AlbumCell") as! AlbumTableViewCell


        return myInfo

      default:
        let cell = tableView.dequeueReusableCellWithIdentifier("TravelBookCell") as! TravelBookTableViewCell


        return cell

    }
}

person user3708224    schedule 27.07.2015    source источник


Ответы (1)


Вы можете переключить размер рамки ячейки. Вот пример для случая 0 переключателя.

    case 0:
            let myProfile = tableView.dequeueReusableCellWithIdentifier("ProfileHeaderCell") as! VideoTableViewCell

myProfile.frame.size = CGSize(width: /*CGFloat*/, height: /*CGFloat*/)  

            return myProfile
person Epic Defeater    schedule 27.07.2015
comment
высота не меняется...? myProfile.frame.size = CGSize (ширина: 600,0, высота: 60,0) вернуть мой профиль - person user3708224; 27.07.2015
comment
Странно, вы где-нибудь поменяли rowHeight? Если вы хотите, вы также можете сделать это в раскадровке, увеличив ячейку? Дважды проверьте, поставив большую высоту, например 350. - person Epic Defeater; 27.07.2015
comment
на данный момент все высоты ячеек для всех 3 разделов входят в настройки высоты строки представления таблицы раскадровки ... поэтому я полагаю, что мне нужно переопределить это или каким-то образом установить это значение высоты строки таблицы в пустое ...? - person user3708224; 27.07.2015