Post

Replies

Boosts

Views

Activity

UICollectionViewCell UI bugs
Hey guys. Cut to the chase. Trynna create some cells in my CollectionView. Cells will populate with the object of type Tweet. Some Tweet(s) has urlToExpand, some has value nil. Based on that, button "See more" will be visible or nah. I am certain that the data is passed correctly into Cell as I have checked it with the print. However button works randomly. Sometimes it does display, sometimes it doesn't. I have no idea why. Here is my dataSource update in VC private func configureDataSource() { &#9;&#9;&#9;&#9;dataSource = UICollectionViewDiffableDataSource<Section, Tweet>(collectionView: collectionView, cellProvider: { (collectionView, indexPath, tweet) -> UICollectionViewCell? in &#9;&#9;&#9;&#9;&#9;&#9;let cell = collectionView.dequeueReusableCell(withReuseIdentifier: SearchTweetsCell.reuseId, for: indexPath) as! SearchTweetsCell &#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;cell.set(with: tweet, user: self.user) &#9;&#9;&#9;&#9;&#9;&#9;cell.delegateSafari = self &#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;return cell &#9;&#9;&#9;&#9;}) &#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;dataSource.supplementaryViewProvider = { (collectionView, kind, indexPath) in &#9;&#9;&#9;&#9;&#9;&#9;let header = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: SearchTweetsVCCollectionHeader.reuseId, for: indexPath) as! SearchTweetsVCCollectionHeader &#9;&#9;&#9;&#9;&#9;&#9;header.set(with: self.user) &#9;&#9;&#9;&#9;&#9;&#9;return header &#9;&#9;&#9;&#9;} &#9;&#9;} Here is the function from collectionViewCell that I am calling in my cv while populating cells. func set(with usersTweet: Tweet, user: User) { &#9;&#9;&#9;&#9;self.user&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; = user &#9;&#9;&#9;&#9;tweet&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; = usersTweet &#9;&#9;&#9;&#9;urlString&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; = usersTweet.urlToExpandWithSafari &#9;&#9;&#9;&#9;tweetBodyLabel.text&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; = usersTweet.tweetText &#9;&#9;&#9;&#9;timeDateLabel.text&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;= usersTweet.createdAt.formatToTwitterPostDate() &#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;sharesView.set(itemInfoType: .shares,&#9; with: usersTweet.retweetCounter.convertToKMFormatStr()) &#9;&#9;&#9;&#9;likesView.set(itemInfoType: .likes,&#9;&#9; with: usersTweet.likesCounter.convertToKMFormatStr()) &#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;guard tweet.urlToExpandWithSafari != nil else { &#9;&#9;&#9;&#9;&#9;&#9;DispatchQueue.main.async { self.goSafariButton.removeFromSuperview() } &#9;&#9;&#9;&#9;&#9;&#9;goSafariButton.isEnabled = false &#9;&#9;&#9;&#9;&#9;&#9;return &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;DispatchQueue.main.async { self.goSafariButton.setTitle(TweetStrings.seeFull, for: .normal) } &#9;&#9;} Many thanks for any help.
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
1.4k
Mar ’21
Button animation issue
Hey guys. I've created that function to animate my button: 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             }         }     } But the problem is that animation does not finish. Alpha stays at around probably 85% from what I can see. Any help explaining what is wrong with this code will be appreciated! Many thanks.
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
617
Jan ’21
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 &amp; Coordinating, isNavigationHidden: Bool) { var pushedVC: UIViewController &amp; 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
854
Mar ’21
How to improve on AR/VR learning path?
Hi everyone. I am a self-taught iOS developer for around a year and a half. It's going really great so far. But there is nothing that interests me more than AR-related/ Rendering technologies. I am learning by myself about RealityKit, SceneKit, ARKit. Surely it doesn't go fast, but it goes somehow. Don't want to mention the Metal, that one goes really slow. Is anyone able to recommend some courses/ teachings not only about these techs specifically but also about some fundamental knowledge that I could possess to make that learning a little more efficient? When working with Entities and their position, it's clear that I am missing fundamental math. I've searched for some courses about Algebra/Trigonometry but there is a ton of it, and I'm not quite sure which ones should I pick to follow the AR path. I've got all the possible notes from WWDCs about RealityKit/ARKit. But it's not enough. Metal WWDCs are simply too complicated for me at this level. I am trying to catch on to some C++ in my spare time but there is little time left for that. I would highly appreciate your help. Thanks
2
0
2.1k
Jan ’22
RealityKit, move(to:) methods works only without duration parameter
Using move(to:) method to update Entity's position works only if I don't use the the initialiser with duration parameter. sphere.move(to: newTransform, relativeTo: nil, duration: 0.75) // Absolutely no effect sphere.move(to: newTransform, relativeTo: nil) // Instant effect Both called from the Main thread. I don't understand what may cause this strange behaviour.
0
0
895
Oct ’22
position of SCN Objects - beginner's question
Hey guys. I am having a little one with the ARKit. Not gonna lie that things is dope. Anyway, These are CGFloat values for SCNSphere ballNode.position = SCNVector3(0.5, -0.3, -1) These are for SCNText labelNode.position = SCNVector3(-50, 0, -100) To place the Sphere where I wanted to I had to use, I Suppose, meters. However for placing the Text I used centimetres. Why? Would anyone be that helpful and redirected me to some documentation about this as I did not find anything? Many Thanks
1
0
711
Dec ’20
UITableView in VC
Hey guys. I am trying to add UITableView do the View of my VC. On top of the VC I added to UIViews with the custom elements and they work just fine. However. When I am trying to add UITableView, it pushes UIViews from above out of the screen. Syntax error - https://developer.apple.com/forums/content/attachment/04148dec-e53f-4473-b647-e317c8709e6e         noteTableView = UITableView(frame: .zero)         view.addSubview(noteTableView)         noteTableView.layer.borderColor = UIColor.systemRed.cgColor         noteTableView.layer.borderWidth = 5                  NSLayoutConstraint.activate([             noteTableView.topAnchor.constraint(equalTo: addNoteView.bottomAnchor, constant: 0),             noteTableView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0),             noteTableView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0),             noteTableView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0),         ])     } This is how I configured it. addNoteView is the UIView above. What am I doing wrong? Many thanks for help
4
0
868
Dec ’20
Using Objective-C Singleton in Swift file within Objective-C project
Hello everyone, I've got my project written in Objective-C. I am learning about bridging. I bridged successfully Swift into my Objective-C project. I did some VC pushing between Objective-C VC and Swift VC. Everything works as it supposed to. However, I created the reference to my Objective-C NetworkManager (I used Singleton pattern) in my Swift file like that: let networkManager = NetworkManager.sharedManager() For some reason I cannot use methods from it. networkManager.getUserInfo() // .getUserInfo() will not appear! Just to show you how I've created my NetworkManager as a Singleton. I found that solution online and it was quite old, if you have any better solution, I would be more than happy to get some insight: (id)sharedManager { static NetworkManager *sharedMyManager = nil; static dispatch_once_t onceToken; dispatch_once(&amp;onceToken, ^{ sharedMyManager = [[self alloc] init]; }); return sharedMyManager; } (id)init { if (self = [super init]) { someProperty = @"Default Property Value"; self.cache = [[NSCache alloc] init]; } return self; } Not sure what is the issue here. Thank you all for the help.
3
0
1.8k
May ’21
TipUIPopoverViewController disables all the views from presenting screen
when using Tips with UIKit, presenting TipUIPopoverViewController disables all the buttons from the presenting screen. I assume this is the expected behaviour but is there a way to disable it? I would like the button that the tip is pointing to to be still enabled. Otherwise user has to tap on it twice which is not ideal. Method checking for tip's eligibility. private extension MenuViewController { func activateTips() { Task { @MainActor [weak self] in guard let self else { return } for await shouldDisplay in createMapTip.shouldDisplayUpdates { if shouldDisplay { let controller = TipUIPopoverViewController(createMapTip, sourceItem: createMapButton) { [weak self] action in if action.id == "LearnAboutMaps" { if self?.presentedViewController is TipUIPopoverViewController { self?.dismiss(animated: true) { self?.createMapTip.invalidate(reason: .actionPerformed) self?.viewModel.handle(.didTapLearnMoreAboutMaps) } } } } present(controller, animated: true) } else if presentedViewController is TipUIPopoverViewController { dismiss(animated: true) } } } } }
2
0
1.3k
Oct ’23
Bug: Tip comes back as pending first, then available when reloading screen
When loading screen, I scan for tips: private lazy var scanAreaTipTask = Task { @MainActor in for await shouldDisplay in scanAreaTip.statusUpdates { if shouldDisplay == .available { onSetBeacon.send(.scanArea(scanAreaTip, .show)) } else { onSetBeacon.send(.scanArea(scanAreaTip, .hide)) scanAreaTipFinished = true } } } Task is called in ViewDidAppear of the UIViewController. First time I load this view controller, the scanAreaTip.statusUpdates always comes back as pending. If I quit this view controller and open it again, the scanAreaTip.statusUpdates will come back as available. Why does it always come back as pending on the first opening where it should come back as available? This is the tip that I am using. As shown, there aren't any rules or options used. Just a plain tip that should show straight away. public struct ScanAreaTip: Tip { public init() {} public var title: Text { Text("Scan area around you") .brandFont(style: .regular(.headline)) .foregroundStyle(Color.accentColor) } }
1
0
795
Oct ’23