我尝试使用reloadRowsAtIndexPaths
或reloadSections
重新加载特定的tableView单元格,当该单元格中的分段开关发生变化时(这反过来又改变了UIScrollView
内的UICollectionView
那个细胞)。使用此选项会导致最后一个tableView单元格(与重新加载的单元格无关)闪烁:单元格的背景会短暂变为黑色。最后一个tableView单元格与另一个不同,因为它包含backgroundView
(参见下图)。 tableView中的所有单元格都清晰,//tableView cellForRowAtIndexPath
case .cellToReload:
let cell = tableView.dequeueReusableCellWithIdentifier("graphs", forIndexPath: indexPath) as! WeatherTableViewCell
cell.selectionStyle = UITableViewCellSelectionStyle.None
let segmentControl = cell.viewWithTag(1) as! UISegmentedControl
segmentControl.selectedSegmentIndex = segment
segmentControl.addTarget(self, action: "segmentAction:", forControlEvents: .ValueChanged)
cell.graph.delegate = self
cell.graph.showsHorizontalScrollIndicator = false
if segment == 0 || segment == 1 {
cell.graph.contentSize.width = cell.frame.width * 2.0
} else {
cell.graph.contentSize.width = cell.frame.width
}
cell.graph.contentSize.height = cell.graph.frame.height
let ConditionsView = UIView(frame: CGRectMake(20, 0, cell.graph.contentSize.width, cell.graph.contentSize.height))
cell.backgroundColor = UIColor.clearColor()
switch (segment) {
//create new view and add as a subview to cell.graph
case .flickeringCell:
let cell = tableView.dequeueReusableCellWithIdentifier("weeklyWeatherCell", forIndexPath: indexPath) as! WeatherTableViewCell
cell.selectionStyle = UITableViewCellSelectionStyle.None
cell.forecastCollectionView.delegate = self
cell.forecastCollectionView.dataSource = self
cell.forecastCollectionView.reloadData()
cell.forecastCollectionView.tag = indexPath.row
cell.forecastCollectionView.showsHorizontalScrollIndicator = false
cell.backgroundColor = UIColor.clearColor()
cell.forecastCollectionView.backgroundView = cell.backgroundView
cell.forecastCollectionView.backgroundColor = cell.backgroundColor
return cell
func segmentAction(sender: UISegmentedControl) {
let path = NSIndexSet(index: 1)
switch sender.selectedSegmentIndex {
case 0:
segment = 0
tableView.reloadSections(path, withRowAnimation: .Fade)
case 1:
segment = 1
tableView.reloadSections(path, withRowAnimation: .Fade)
case 2:
segment = 2
tableView.reloadSections(path, withRowAnimation: .Fade)
default:
break
}
}
//Table background
func createGradientForTable {
let gradientLayer = CAGradientLayer()
...
gradientLayer.startPoint = CGPoint(x: 0, y: 0)
gradientLayer.endPoint = CGPoint(x: 0, y: 1)
let backgroundView = UIView(frame: sender.tableView.frame)
backgroundView.layer.insertSublayer(gradientLayer, atIndex: 0)
sender.tableView.backgroundView = backgroundView
}
控制背景颜色渐变。
#####################
# Uploading multiple#
# Images #
#####################
$files = $_FILES;
$count = count($_FILES['uploadfile']['name']);
for($i=0; $i<$count; $i++)
{
$_FILES['uploadfile']['name']= $files['uploadfile']['name'][$i];
$_FILES['uploadfile']['type']= $files['uploadfile']['type'][$i];
$_FILES['uploadfile']['tmp_name']= $files['uploadfile']['tmp_name'][$i];
$_FILES['uploadfile']['error']= $files['uploadfile']['error'][$i];
$_FILES['uploadfile']['size']= $files['uploadfile']['size'][$i];
$this->upload->initialize($this->set_upload_options());//function defination below
$this->upload->do_upload('uploadfile');
$upload_data = $this->upload->data();
$name_array[] = $upload_data['file_name'];
$fileName = $upload_data['file_name'];
$images[] = $fileName;
}
$fileName = $images;
带有UICollectionView的TableView单元格:
答案 0 :(得分:1)
我删除了那个视觉效果视图,并通过向collectionView添加背景来实现相同的效果。视觉效果视图是闪烁的,而不是单元格或其中的其他视图。我通过编辑实现了与视觉效果视图相同的效果:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
包括:
collectionView.backgroundColor = UIColor.whiteColor().colorWithAlphaComponent(0.25)
答案 1 :(得分:0)
记住在主线程上更新UI以调度和异步任务时:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
dispatch_async(dispatch_get_main_queue()) {
self.tableView.reloadData()
}
}