Post

Replies

Boosts

Views

Activity

Using viewForHeaderInSection to get customized header in story board
I need to create a section header for a tableview, and I don't want to create it in single Xib, I added one in storyboard, but the header need some customization, so I create a file looks like this: class CustomizedTipsView: UITableViewHeaderFooterView {     @IBOutlet weak var tipTitle: UILabel!     @IBOutlet weak var tipContent: UILabel! } And I want to use the header in viewForHeaderInSection func like this: if let header = tableView.dequeueReusableHeaderFooterView(withIdentifier: "CustomizedTipsView") as? CustomizedTipsView {             header.tipTitle.text = "1"             header.tipContent.text = "2" } if I register the cell, it crash, if not, the cell always returns nil. //crash mainTableView.register(UINib(nibName: "CustomizedTipsView", bundle: nil), forHeaderFooterViewReuseIdentifier: "CustomizedTipsView") //crash too mainTableView.register(CustomizedTipsView.self, forHeaderFooterViewReuseIdentifier: "CustomizedTipsView") Do I have to use the UITableViewCell instead of simple CustomizedTipsView for view from storyboard? Thank you for your help!
2
0
898
Apr ’21
How to change Tabbar image in SwiftUI
I have a Tabbar which is created by SwiftUI, but I use different images for different status of selected Tabbar(selected and unselected), how can I do that. I tried to change image name in TabView1().onAppear() { tabImageName1 = "image1_active" tabImageName2 = "image2" tabImageName3 = "image3" tabImageName4 = "image4" } seems this not worked, and I think it's not so elegant, how can I change the image rightly, do we have better ways to do thing like this?
1
0
5.5k
Jan ’21
Swift execute code after return, unbelievable!!
I created a tableview and there is a toggle in a cell, I click the toggle there will be an function in the cell's protocol, and in the implement of the function I have a logic like this:  extension NewPortfolio: PortfolioBasicInfoCellProtocol {     func privacyButtonEvent() {         if !privacyModeOn {             return             print("what?") //            basedOnFiatCur.toggle() //            let preferences = UserDefaults.standard //            preferences.set(basedOnFiatCur, forKey: "basedOnFiatCur") //            NotificationCenter.default.post(name: .toggledBaseCurFromModal, object: nil) //            UISelectionFeedbackGenerator().selectionChanged() //            mainTable.reloadData()         }     } } then compiler print: what? The print function after the return is executed! can't believe this anybody know why? or this is a bug of apple?
1
0
1.4k
Jan ’21