How can I take a text of textfield, and make it as name of a section in a tableview? I want to do this in Swift and Xcode 6. Thank you very much.
You can use titleForHeaderInSection.
func tableView(tableView: UITableView!, titleForHeaderInSection section: Int) -> String!{
if (section == 0){
return textfield.text
}
if (section == 1){
return textfield2.text
}
}
SWIFT 3.0 come from @Christian 's answer.
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
if section == 0 {
return ""
} else {
return ""
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With