2017-04-22 6 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 헤더를 취할 수 있습니다. 심지어 정적 뷰를 취할 수도 있고 그 아래에서 your_table_view를 추가 할 수도 있습니다. 정적보기에서 라벨, searchbar 등을 추가하십시오. –

답변

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 
} 
관련 문제