2016-08-16 15 views
0

私は多くの情報を表示するビューを実装しています。ビューはスクロール可能であり、ビューの中で私はユーザーのコメントを保持するスクロール不可能なテーブルビューを実装しました。私はすべての自動レイアウトの制約を受けていますが、レイアウトは正しく表示されますが、タッチは特定の行の下には届きません。テーブルビューまたは何かがイベントの受信から以下のビューをブロックしているように見えますが、問題をトレースすることができません。UITableViewCellは接触を受け取りません

コメントテーブルのビューが大きくなるにつれ、メインスクロールビューのコンテンツサイズが大きくなるようにします。ポストコメントビューをテーブルビューの下部に保持する。今、私は最後のセルまたはテキストフィールドを選択することはできません。ここで

コメント細胞ビュー Comment Cell View

シミュレータのスクリーンショット 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

あなたはこれらのイベントを発射するtrueにuserInteractionEnabledを設定する必要があります。

view.userInteractionEnabled = true 
0

コメントTextFieldは、コメントTableViewの最後の行です。次のようにコメントのTextFieldコードは、テーブルビューのフッターに入れる:

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 
    } 

のtableViewフッターとしてコメントのTextFieldビューを割り当てる別の方法があります:

myTableView.tableFooterView = commentTextFieldView

関連する問題