我想在iOS中顯示自己將包含列表的列表。 例如,我想創建一個日期明確的任務列表,其中日期和任務是動態的。所以外部列表是日期列表,內部列表將是任務列表。也希望處理點擊任務。 如何在iOS中實現這一點,嘗試使用表視圖,但無法實現它,因爲我想顯示嵌套列表。簡而言之,我想在iOS中顯示列表的列表。如何在iOS中顯示自定義嵌套列表
0
A
回答
2
//
// 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()
}
}
+0
@ Ishika-謝謝!我也參考了這個[TableView中的CollectionView](https://github.com/ashfurrow/Collection-View-in-a-Table-View-Cell) –
+0
它的我的榮幸:) – Ishika
相關問題
- 1. 顯示在列中的嵌套列表
- 2. 如何自定義SharePoint 2007自定義列表中列的顯示?
- 3. 如何在Civicrm Drupal 7中顯示嵌套的自定義數據集?
- 4. 教程如何在WPF中顯示自定義類的列表
- 5. 在Pyspc中使用自定義嵌套列表時發生AssertionError
- 6. 如何顯示Xamarin表單中的項目的嵌套列表?
- 7. 反序列化自定義JsonConverter中的嵌套對象列表
- 8. 如何顯示嵌套屬性定義在Apiary.io
- 9. Sitefinity自定義列表模板嵌入式圖像不顯示
- 10. gson嵌套自定義序列化器
- 11. 如何在圖表中表示列表中的列表中的嵌套列表?
- 12. 如何顯示Drupal頁面中的自定義對象列表
- 13. 在Vue中嵌套自定義標籤
- 14. 顯示自定義的下拉列表
- 15. 自定義列表不顯示數據
- 16. 遞歸顯示嵌套列表
- 17. angular2顯示嵌套的json列表
- 18. C#序列化嵌套自定義類列表
- 19. 列表視圖與自定義列布局嵌套LinearLayouts
- 20. 自定義視圖:嵌套linearlayout沒有顯示
- 21. 自定義嵌套路線
- 22. 嵌套自定義元素
- 23. 在Drupal中顯示自定義內容類型中的嵌套字段組
- 24. 如何在asp.net webform中顯示來自嵌套ICollection的數據
- 25. 如何在列表理解中表示嵌套的fors?
- 26. 如何在多表中嵌套中繼器顯示數據?
- 27. 如何在fxml文件中定義JavaFX中的嵌套列?
- 28. 顯示嵌套表單
- 29. cakephp自定義驗證不會在嵌套規則中顯示錯誤消息
- 30. 如何並排定位嵌套列表?
你可以在tableView裏面使用tableView或tableView裏面的collectionview。如果您可以分享正確要求的圖像,我可以幫助您更多。 – Ishika
你可以在tableview –
目標C或swift中共享任何使用tableview的參考嗎? – Ishika