I have a cell with a button on it. When I press the button, I start an animation indicating something is preparing. I do this within the @IBAction
function like so: (this is in my custom tableViewCell function).
@IBAction func playNowTapped(_ sender: UIButton) {
let loadingShape = CAShapeLayer()
//Some animating of the shape
}
I define this shape within the @IBAction
as the process should repeat if I press the button again
However, because only the necessary cells displayed on the device are loaded in one chunk in the cellForRowAt
function for the tableView, my animation repeats every few cells if I scroll down while the animation is loading.
What I have done so far is append to a list of all the previously pressed buttons in my by defining a function and calling it in the @IBAction
function of the button like so:
func findCell() {
//Iterate tableView list and compare to current cellText
for value in list {
if value == cellText.text {
//If found, checking if value is already stored in pressedBefore
for selected in pressedBefore {
if selected == value { return }
}
alreadyPlay.append(song: cellText.text!)
}
}
}
Then, in my cellForRowAt
function, I simply make a reverse operation, which checks if the current index in the list is the same as any value in the already selected ones.
Having all of these filtered out, I now only have a list of the non-selected ones.However, I do not know what to do now.
Weirdly, cell.bringSubview(tofront: cell.cellText)
cell.bringSubview(tofront: cell.buttonText)
does NOT change the order of the subviews. What would do I do now? Is it possible that CAShapeLayer()
is not regarded as a subview, but only a layer?
Thank you in advance!