2017-04-22 4 views
0

スクロール中に他のセルは移動しますが、トップセルはその位置にとどまるように、画面上部のtableViewセルをフリーズします。迅速にtableViewセルをフリーズするには?

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
     let cell = tableView.dequeueReusableCell(withIdentifier: "myCell", for: indexPath) 
     cell. //I think it must be here 
     return cell 

ありがとうございます。

+2

は、テーブルビューのヘッダーを作成します。 –

+0

@RajeshkumarRそれを行う方法を説明できますか? – SinaSB

+0

あなたはTableViewヘッダーを取ることができます。あなたは静的なビューを取ることができ、その下にあなたの_table_viewを追加します。静的ビューでは、ラベル、検索バーなどを追加します。 –

答えて

0

これらのメソッドを使用して、テーブルビューヘッダーを作成し、その中にサブビューを追加します。

func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { 
    return 50 
} 
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { 
    let header = UIView.init() 
    header.backgroundColor = UIColor.gray 
    //Add subviews here 
    return header 
} 
1

これを試してみてください。

func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { 
    return 65 
} 
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { 
    let header = view as! UITableViewHeaderFooterView 
    header.textLabel?.textColor = UIColor.black 
header.textLabel?.text="adadafaf"//ur data 
}