2016-05-01 4 views
-3

У меня есть tableView, который показывает содержимое массива.Добавить новый tableView в Swift

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { //currnet table information. 
    let cell = UITableViewCell() 

    if chartTitle[indexPath.row] == "Name" { 
     cell.textLabel?.text = chartTitle[indexPath.row] 
    } 
    else if ... { 
     ...... 
    }  

    return cell 
} 
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
    return chartTitle.count 
} 

Теперь я хочу, чтобы добавить новый Tableview, который показывает содержание другого массива, но это трудно для меня, чтобы реализовать, так как Tableview имеет тот же класс UITableView.

Как добавить новый tableView и управлять его строками в зависимости от другого массива?

Заранее спасибо.

ответ

0

Вы можете проверить в функции cellForRowAtIndexPath и другие подобные numberOfSectionsInTableView, numberOfRowsInSection и т.д.:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 

    if tableView == self.firstTableView { 
      // do something 
    } else if tableView == self.secondTableView { 
      // do something else 

} 
Смежные вопросы