Добавление UITableView в UIView.Добавьте пользовательские ячейки, свяжите пользовательские классы ячеек и внедрите делегаты -UITableviewDelegate и UITableViewDataSource.
case 1: две пользовательских ячейки в табличном представлении
func tableView (tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell: CustomCell!
if indexPath.row == 0{
cell = tableView.dequeueReusableCellWithIdentifier("Cell1ID", forIndexPath: indexPath) as CustomCell
//set cell2
}
if indexPath.row >= 1{
cell = tableView.dequeueReusableCellWithIdentifier("Cell2ID", forIndexPath: indexPath) as CustomCell
let cons = aArray[indexPath.row - 1]
// set cell2
}
return cell
}
case 2: альтернативное отображение пользовательских ячеек (т. е. с использованием uisegmentcontrol)
var CellIdentifier: String = "Cell1ID"
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if (CellIdentifier == "Cell1ID")
{
let cell = tableView.dequeueReusableCellWithIdentifier(CellIdentifier)! as! FirstTableViewCell
//additional code
return cell
}
else {
let cell = tableView.dequeueReusableCellWithIdentifier(CellIdentifier)! as! SecondTableViewReportsCell
//Additional code
return cell
}
}
вариант 3: альтернативные настраиваемые ячейки (т.е. нечетные четные)
var CellIdentifier: String = "Cell1ID"
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell: CustomCell!
if (indexPath.row % 2 == 0) {
let cell = tableView.dequeueReusableCellWithIdentifier(CellIdentifier)! as! FirstTableViewCell
}
else
{
let cell = tableView.dequeueReusableCellWithIdentifier(CellIdentifier)! as! SecondTableViewCell
}
return cell
}