我有一个UITableView Controller类,里面是一个String数组.Table视图有1个单元格原型,其中包含一个带有1个单元原型的UICollectionView.
通过将数组传递到tableview单元格来填充CollectionView,该单元格是UICollectionView Delegate和DataSource.
当我对TableViewController中的数组进行更改并调用self.tableView.reloadData()时,单元格内的CollectionView不会更新.
我该如何解决?
谢谢
编辑:
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
}
Run Code Online (Sandbox Code Playgroud)
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: …Run Code Online (Sandbox Code Playgroud) 我一直试图制作一个按钮来切换另一个div的可见性......这是我正在使用的JavaScript
$(document).ready(function () {
var navwidth = $('div#navigationpanel').css('max-width');
$('div#showhidenav').click(function () {
if ( navwidth == "0px" ) {
$('div#navigationpanel').css('max-width', '850px');
}
else if ( navwidth == "850px" ) {
$('div#navigationpanel').css('max-width', '0px');
}
});
});
Run Code Online (Sandbox Code Playgroud)
并且它确实有效,在第一次点击的leas,但第二次我点击按钮,它应该做相反,以太再次显示或隐藏div.但没有任何反应.
所以要清楚,它适用于第一次点击,但不适用于任何下一次点击