2015-01-25 5 views
2

어떻게 텍스트 필드의 텍스트를 가져 와서 tableview의 섹션 이름으로 만들 수 있습니까? Swift와 Xcode 6에서이 작업을 수행하고 싶습니다. 대단히 감사합니다.섹션 이름 테이블 뷰

+0

테이블의 모든 셀에 UITextField가 있습니까? 아니면 헤더를 설정하는 어딘가에'self.textField'가 있습니까? – Armin

답변

5

titleForHeaderInSection을 사용할 수 있습니다.

func tableView(tableView: UITableView!, titleForHeaderInSection section: Int) -> String!{ 
     if (section == 0){ 
      return textfield.text 
     } 
     if (section == 1){ 
      return textfield2.text 
     } 
    } 
1

SWIFT 3.0 은 @Christian의 대답에서 왔습니다.

func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { 
    if section == 0 { 
     return "" 
    } else { 
     return "" 
    } 
}