Post

Replies

Boosts

Views

Activity

UICollectionView - Changing UI of one specific cell causes changes for every fifth cell
Hey guys. I am having an issue with one of my projects. UICollectionViewCell in my UICollectionView has a plus button with the systemImage "plus". When clicked, its changing to systemImage "checkmark". The issue is, clicking one button, changes UI for every fifth cell. On top of that, animation does not finish. Alpha goes to 0, and then the image is being changed, alpha should go to 1 but never gets there. It stops somewhere between 0.7-0.8. Here is my animation block: private func animateButtonView(_ viewToAnimate: UIView) {         UIView.animate(withDuration: 0.2, animations: {viewToAnimate.alpha = 0}) { [weak self] (true) in             guard let self = self else { return }             switch true {             case true:                 DispatchQueue.main.async { self.addToFavoritesButton.setImage(SFSymbolsAsImg.checkmark, for: .normal) }                 UIView.animate(withDuration: 0.2, animations: {viewToAnimate.alpha = 1} )             case false:                 return             }         }     } Animation block is executed in my objective function that is called in addTarget for a button. I've asked that question on many forums and got not much. I'll appreciate any help. Many thanks!
11
0
2.1k
Mar ’21
Coordinator Pattern - Which way is right?
Hey guys. I am trying to understand the way that Coordinator works. I am cathing myself in building my own the way I shall not (created a function that passes a ViewController which, as I understand, defeats the purpose of a Coordinator. Let us say I have 3 Diffrent ViewControllers that may be initialised from HomeVC depending on a Button. My way of thinking tells me to create something like this: Swift class MainCoordinator: Coordinator { var navigationController: UINavigationController? func pushVCWithUser(viewController: UIViewController & Coordinating, isNavigationHidden: Bool) { var pushedVC: UIViewController & Coordinating = viewController pushedVC.coordinator = self navigationController?.setNavigationBarHidden(isNavigationHidden, animated: true) navigationController?.pushViewController(pushedVC, animated: true) } } and just to initialize it in my VC. But it's not the way it supposed to be done I assume. Or is it actually?  Another way:  I have seen some tutorials when a guy used Enum for cases and created a separate function for each case. But then I don't know how would I pass some parameters while initializing another ViewController. Or shall I rather create a function like the one above but for each individual View Controller and pass the parameter (let us say that VCs are initialized with the number: Int) in a function signature?  Many thanks for any any help!
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
866
Mar ’21