2016-08-16 2 views
0

Я реализую представление, которое отображает много информации. Представление прокручивается, и внутри представления я реализовал прокручиваемый вид таблицы, содержащий комментарии пользователя. У меня есть все ограничения автоматической компоновки, и он выглядит правильно, однако штрихи не принимаются ниже определенной строки. Кажется, что представление таблицы или что-то блокирует представления ниже от получения событий, но я не могу отследить проблему.UITableViewCell не будет получать штрихи

Я хочу, чтобы размер содержимого основного прокрутки увеличивался по мере роста представления таблицы комментариев. Сохранение комментария комментария комментария в нижней части таблицы. Прямо сейчас я не могу выбрать последнюю ячейку или текстовое поле.

Комментария Cell View Comment Cell View

Simulator скриншот Simulator screenshot

Вот код от реализации табличного:

commentsTableView.delegate = self 
    commentsTableView.dataSource = self 
    commentsTableView.estimatedRowHeight = 82 
    commentsTableView.rowHeight = UITableViewAutomaticDimension 
    commentsTableView.sectionHeaderHeight = UITableViewAutomaticDimension 
    commentsTableView.estimatedSectionHeaderHeight = 54 
    commentsTableView.estimatedSectionFooterHeight = 0 
    commentsTableView.sectionHeaderHeight = UITableViewAutomaticDimension 
    commentsTableView.tableFooterView = UIView(frame: CGRectZero) 


func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { 
    return "Comments" 
} 

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
    return comments.count 
} 

func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { 
    if section != 0 { return nil } 

    let sectionTitle: String = self.tableView(tableView, titleForHeaderInSection: section)! 
    if sectionTitle == "" { 
     return nil 
    } 

    let view = UIView(frame: CGRectMake(0, 0, tableView.frame.width, 54)) 
    let title = UILabel(frame: CGRectMake(60, 22, tableView.frame.width, 17)) 
    view.addSubview(title) 

    title.text = sectionTitle 
    title.textColor = UIColor(red: (74/255), green: (74/255), blue: (74/255), alpha: 1.0) 
    title.backgroundColor = UIColor.clearColor() 
    view.backgroundColor = UIColor.clearColor() 
    title.font = UIFont(name: "ProximaNova-Semibold", size: 16.0) 

    view.layer.addBorder(.Bottom, color: UIColor.lightGrayColor().colorWithAlphaComponent(0.75), thickness: 0.5) 
    title.setNeedsDisplay() 
    view.setNeedsDisplay() 

    return view 
} 
+0

Вы добавить didselect функция для просмотра таблицы? –

ответ

0

Вы должны установить userInteractionEnabled истину уволить те события ,

view.userInteractionEnabled = true 
0

Комментарий TextField - это последняя строка вашего комментария TableView. Так поместить комментарий TextField код в футере TableView следующим образом:

func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { 
     let commentTextFieldView = UIView(frame: CGRectMake(0, 0, tableView.frame.size.width, 50)) 

     // Your Comment TextField code 

     return commentTextFieldView 
    } 

    func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { 
     return 50.0 
    } 

Существует другой способ назначить Комментарий вид TextField в Tableview сноски:

myTableView.tableFooterView = commentTextFieldView

Смежные вопросы