I'm experiencing a strange issue with my UIKit app. I have a UITableView
that contains a UICollectionView
. The UITableView
gets reloaded every few seconds, but after each reload, the size of the SF Symbols inside the UICollectionView
cells changes slightly, as you can see in this example (I've set the reload timer to 1 second for demonstration purposes).
I'm not sure if this issue is caused by my unusual table view/collection view configuration or if it's an Apple bug. Does anyone know a solution to this problem?
Here's the relevant code:
This is inside my ViewController
:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
...
productsCollectionView.reloadData()
return cell
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "verbindungCollectionViewCell", for: indexPath) as! verbindungCollectionViewCell
if legArray[tempIndexPathFromTableView.row][0][indexPath.row] is PublicLeg {
//Public Leg
var tempPublicLeg = legArray[tempIndexPathFromTableView.row][0][indexPath.row] as! PublicLeg
cell.serviceLabel.text = tempPublicLeg.line.label
cell.serviceImageView.image = getProductSymbol(productType: productToTransportType(product: tempPublicLeg.line.product!), designPack: .automatic)
cell.setCancelled(tempPublicLeg.isCancelled)
if tempPublicLeg.isCancelled == true {
}
} else {
//Individual Leg (Walk)
var tempIndLeg = legArray[tempIndexPathFromTableView.row][0][indexPath.row] as! IndividualLeg
cell.serviceImageView.image = getProductSymbol(productType: .walk, designPack: .automatic)
cell.serviceLabel.text = tempIndLeg.departure.getDistanceText(CLLocation(latitude: CLLocationDegrees(tempIndLeg.arrival.coord?.lat ?? 0)/1000000, longitude: CLLocationDegrees(tempIndLeg.arrival.coord?.lon ?? 0)/1000000))
}
return cell
}
This is the function that returns the SF Symbols:
func getProductSymbol(productType: TransportType, designPack: DesignPack) -> UIImage? {
...Determinate color, symbol etc...
if colorType == .singleColor {
let config = UIImage.SymbolConfiguration(hierarchicalColor: colors[0])
let image = UIImage(systemName: symbolName, withConfiguration: config)?.withRenderingMode(.automatic)
return image
} else if colorType == .multipleColor {
let config = UIImage.SymbolConfiguration(paletteColors: colors)
let image = UIImage(systemName: symbolName, withConfiguration: config)?.withRenderingMode(.automatic)
return image
} else {
return nil
}
}
And here is my UIViewController
in Storyboard:
Thank you all in advantage.