我正在构建一个iOS应用程序,其中UITableView中有4种不同的UICollectionViewn设计。
UICollectionViewCell类名称是:DealCollectionViewCell,FilterCollectionViewCell,ComboCollectionViewCell,BusinessCollectionViewCell
UITableViewCell类名称是:DealTableViewCell,BusinessTableViewCell,FilterTableViewCell,ComboTableViewCell
下面是UIViewController类代码(类名HomeViewControllerr)
类扩展
UIViewController, UITableViewDelegate, UITableViewDataSource, UICollectionViewDelegate, UICollectionViewDataSource
Run Code Online (Sandbox Code Playgroud)
对于UITableView
func tableView(_ tableView:UITableView,numberOfRowsInSection部分:Int)-> Int {return 4}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.row == 0
{
let cell = tableView.dequeueReusableCell(withIdentifier: "DealTableViewCellId") as! DealTableViewCell
return cell
}
else if indexPath.row == 1
{
let cell = tableView.dequeueReusableCell(withIdentifier: "FilterTableViewCellId") as! FilterTableViewCell
return cell
}
else if indexPath.row == 2
{
let cell = tableView.dequeueReusableCell(withIdentifier: "ComboTableViewCellId") as! ComboTableViewCell
return cell
}
else
{
let cell = tableView.dequeueReusableCell(withIdentifier: …Run Code Online (Sandbox Code Playgroud)