Я хочу получить заголовок заголовка в разделе UITableView, пожалуйста, подскажите мне, что такое синтаксис в swift, чтобы получить заголовок заголовка в разделе.UITableView get titleForHeadersInSection swift
func tableView(tableView : UITableView, titleForHeaderInSection section: Int)->String
{
switch(section)
{
case 2:return "Title 2"
break
default :return ""
break
}
}
func tableView (tableView:UITableView , heightForHeaderInSection section:Int)->Float
{
var title = tableView.titleForHeaderInSection[section];
if (title == "") {
return 0.0;
}
return 20.0;
}
func tableView (tableView:UITableView, viewForHeaderInSection section:Int)->UIView
{
var title = tableView.titleForHeaderInSection[section] as String
if (title == "") {
return UIView(frame:CGRectZero);
}
var headerView:UIView! = UIView (frame:CGRectMake(0, 0, self.tableView.frame.size.width, 20.0));
headerView.backgroundColor = self.view.backgroundColor;
return headerView;
}
Почему разве вы не используете номер раздела для сравнения вместо названия? – zisoft
На самом деле я хочу знать синтаксис, чтобы получить заголовок для заголовка в разделе. –