如何在iOS中显示自定义嵌套列表
我想在iOS中显示一个列表,该列表本身将包含一个列表。 例如,我想创建一个每日任务列表,其中日期和任务是动态的。因此,外部列表是日期列表,内部列表是任务列表。我还想处理单击任务。如何在iOS中显示自定义嵌套列表,ios,swift,list,uitableview,uiscrollview,Ios,Swift,List,Uitableview,Uiscrollview,我想在iOS中显示一个列表,该列表本身将包含一个列表。 例如,我想创建一个每日任务列表,其中日期和任务是动态的。因此,外部列表是日期列表,内部列表是任务列表。我还想处理单击任务。 如何在iOS中实现这一点,已尝试使用表视图,但无法实现,因为我想显示嵌套列表。简而言之,我想在iOS中显示列表列表。您可以在tableView中使用tableView,也可以在collectionview中使用tableView。如果您能分享所需的图片,我可以为您提供更多帮助。您能分享在tableview Object
如何在iOS中实现这一点,已尝试使用表视图,但无法实现,因为我想显示嵌套列表。简而言之,我想在iOS中显示列表列表。您可以在tableView中使用tableView,也可以在collectionview中使用tableView。如果您能分享所需的图片,我可以为您提供更多帮助。您能分享在tableview Objective C或swift中使用tableview的任何参考吗?您可以使用tableview,其中部分为日列表,行(单元格)为Tasklist@Ishika-在SwiftView中,您可以在tableView中使用tableView,也可以在collectionview中使用tableView。如果您能分享所需的图片,我可以为您提供更多帮助。您能分享在tableview Objective C或swift中使用tableview的任何参考吗?您可以使用tableview,其中部分为日列表,行(单元格)为Tasklist@Ishika-在Swift@Ishika-谢谢大家!!“收集”视图在“表格”视图中起作用了,我也参考了这一点,这是我的荣幸:)@Ishika谢谢!表视图中的集合视图起作用了,我也从中引用了它(这是我的荣幸:)
//
// ViewController.swift
// Ishika
//
// Created by IShika on 12/06/17.
// Copyright © 2017 Ishika. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var viewForHeader: UIView!
@IBOutlet weak var tblViewForHome: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
}
extension ViewController: UITableViewDataSource,UITableViewDelegate{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell = UITableViewCell()
cell = tblViewForHome.dequeueReusableCell(withIdentifier: "FeaturedLocationsCell") as! FeaturedLocationCellClass
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
//It should be greater than your collectionViewCell's size
return 300.0
}
}
//MARK:- UITABLEVIEWCELL CLASS
class FeaturedLocationCellClass : UITableViewCell,UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout {
@IBOutlet weak var colVForFeaturedLocations: UICollectionView!
override func awakeFromNib() {
super.awakeFromNib()
colVForFeaturedLocations.dataSource = self
colVForFeaturedLocations.delegate = self
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 2
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = colVForFeaturedLocations.dequeueReusableCell(withReuseIdentifier: "myFeautredLocationColVCell", for: indexPath) as! MyFeaturedLocationCollCellClass
return cell
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize{
return CGSize(width: screenWidth/2 + 50 , height: screenWidth/2 + 50)
}
}
//MARK:- UICOLLECTIONVIEWCELL CLASS
class MyFeaturedLocationCollCellClass: UICollectionViewCell{
//Can draw outlets for your collectionView elements
override func awakeFromNib() {
super.awakeFromNib()
}
}