Post

Replies

Boosts

Views

Activity

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.
0
0
571
Jan ’21
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.
0
0
1.3k
Jan ’21
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
771
Dec ’20
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
628
Dec ’20
Adjust UI elements to the screen size
Hey. I googled for the solution but haven't seen anything posted less than a year ago, so Im here. I am trying to adjust UIButtons, images, all the layout of my app to the size of smaller screen like iPhone 7 and SE 2nd generations. Rest of the layout is fine. Is there any way to change layout specifically just to those two models? If not, how can I do it instead? Many thanks for help.
0
0
466
Nov ’20
Tap gesture UIImageView
Hey guys. Here is what I am trying to do: Ive created and UIImageView that displays an image. Ive created an UILabel (3/4 size of the image) When I tap an image, Id like that UILabel to cover part of that image. Any clues how to do that? Ive tried addTapGestureRecognizer but Im not sure how to do it in a best way. Any help appreciated. Ive seen some documentation but I don't not understand how to use those informations in practise.
1
0
420
Nov ’20
split the string
Hi, Id like to split the string = "aabbccddee". .split function requires you to use some sort of separator. Any suggestion how to make it? The main task is actually to count how many times the letters appear in a string. I believe the solution may be related to .map. Any help appreciated.
3
0
562
Sep ’20
line of code
Hey guys. var d = 5 var s = "String of words" var words = s.split(separator: " ") var howMany = words.count var howLong = words[2].count var result = [words[0].count] for b in 0..<howMany {   var tem = words[0].count   if result > tem {     result = tem   }     } line 8 and 9 displays the following info: Cannot convert value of type '[Int]' to expected argument type 'Int' What am I doing wrong? Any help appriciated. Thank You
1
0
558
Sep ’20