मेरे पास एक UITableView नियंत्रक वर्ग है, और इसके अंदर एक स्ट्रिंग सरणी है। तालिका दृश्य में 1 सेल प्रोटोटाइप है और इसमें 1 सेल प्रोटोटाइप के साथ एक UICollectionView है।
संग्रह व्यू टेबल व्यू सेल में सरणी को पास करके पॉपुलेटेड है, जो कि UICollectionView प्रतिनिधि और डेटा स्रोत है।
जब मैं TableViewController के अंदर सरणी में परिवर्तन करता हूं, और self.tableView.reloadData () को कॉल करता हूं, तो सेल के अंदर संग्रह दृश्य अपडेट नहीं होता है।
मैं यह कैसे तय करुं?
धन्यवाद
संपादित करें:
TableViewController में कोड:
@IBAction func addToArrayAction(sender: AnyObject) {
self.testArray.append("Ant-Man")
self.tableView.reloadData()
}
var testArray = ["Guardinas", "Iron Man", "Avengers", "Captain America"]
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("collectionContainerCell", forIndexPath: indexPath) as! TableViewCell
cell.testArray = self.testArray
return cell
}
UITableViewCell में कोड:
var testArray: [String]?
override func awakeFromNib() {
super.awakeFromNib()
self.collectionView.delegate = self
self.collectionView.dataSource = self
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = self.collectionView.dequeueReusableCellWithReuseIdentifier("collectionViewCell", forIndexPath: indexPath) as! CollectionViewCell
cell.movieTitleLabel.text = self.testArray![indexPath.item]
cell.movieYearLabel.text = "2016"
return cell
}
2 जवाब
कृपया सरणी में प्रत्येक अद्यतन पर UICollectionView
के reloadData
को कॉल करने का प्रयास करें। यदि आप UITableView
में केवल एक सेल का उपयोग कर रहे हैं तो आप cellForRowAtIndexPath
विधि UITableView
में पुनः लोड कर सकते हैं अन्यथा UITableView
reloadData
कॉल करने के बाद कॉल कर सकते हैं।
जब मैंने cell.collectionView.reloadData () जोड़ा, उसके बाद CollectionView स्क्रॉलिंग मेरे प्रोजेक्ट में बहुत धीमी है। उस तरह की समस्या को कैसे हल किया जाए।
संबंधित सवाल
जुड़े हुए प्रश्न
नए सवाल
ios
iOS, Apple iPhone, iPod टच और iPad पर चलने वाला मोबाइल ऑपरेटिंग सिस्टम है। IOS प्लेटफॉर्म पर प्रोग्रामिंग से संबंधित प्रश्नों के लिए इस टैग [ios] का उपयोग करें। उन प्रोग्रामिंग भाषाओं के लिए विशिष्ट मुद्दों के लिए संबंधित टैग [उद्देश्य-सी] और [स्विफ्ट] का उपयोग करें।