Swift 在同一表视图中放置多个类型的TableViewCells

Swift 在同一表视图中放置多个类型的TableViewCells,swift,uitableview,Swift,Uitableview,我有一个表视图,当前正在显示在XIB文件中创建的一种类型的tableViewCell,我希望在表视图中的任意位置显示另一种类型的XIB文件。e、 例如,在桌面视图中的任意Post位置有广告显示单元 我怎样才能做到这一点。我目前有以下代码用于显示一个单元格: func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { le

我有一个表视图,当前正在显示在XIB文件中创建的一种类型的tableViewCell,我希望在表视图中的任意位置显示另一种类型的XIB文件。e、 例如,在桌面视图中的任意Post位置有广告显示单元

我怎样才能做到这一点。我目前有以下代码用于显示一个单元格:

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

        let cardioCell:CardioItemsTableViewCell! = tableView.dequeueReusableCellWithIdentifier("CardioItemsTableViewCell") as? CardioItemsTableViewCell
cardioCell.cellNameLabel.text = "Test String"

return cardioCell!

}
我有一张苹果新闻应用程序的图片,其中一个手机没有图片。但在我的例子中,单元格与其他单元格完全不同,布局也不同

任何想法都将不胜感激


不能随机加载传感器。您需要有一个特定的逻辑,在此基础上,您可以加载不同类型的tableViewCell。

感谢的可能副本。正是我所需要的
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    if indexPath.row % 2 == 0
        let cardioCell:CardioItemsTableViewCell! = tableView.dequeueReusableCellWithIdentifier("CardioItemsTableViewCell") as? CardioItemsTableViewCell
        cardioCell.cellNameLabel.text = "Cells with even number of row"
        return cardioCell!

    else if indexPath.row % 2 != 0
        let otherTypeCell:OtherTypeTableViewCell! = tableView.dequeueReusableCellWithIdentifier("OtherTypeItemsTableViewCell") as? OtherTypeTableViewCell
        otherTypeCell.cellNameLabel.text = "Cells with odd number of row"
        return otherTypeCell!
}