Post

Replies

Boosts

Views

Activity

Keeping UITextFields width the same in a static TableView
Hi all,I have a static TableView with text fields. I want them to have the same width, but I can't make "relative constraint" (with ctrl, or how it's called) to each other because they placed in different cells. As a workaround, I made fixed width constraints, but now xcode shows warnings "fixed width constraints may cause clipping". So I wonder if there is a better way?Those text fields are for numbers only, so probably there will be no localization issues.
1
0
589
May ’20
Generating strings file with genstrings
Hey all, I'm developing a fully programmatically app (not sure if it matters) and get to the point where I want to localize it. Most of my strings are look like this: swift cell.label.text = localized("Hello world") where localized() is just a wrapper around NSLocalizedString(): swift func localized(_ string: String) - String {     return NSLocalizedString(string, comment: "") } So, I added desirable languages to my project and created *.strings file, but when I do bash find ./ -name "*.swift" -exec echo {} \; -exec genstrings -s localized -a -o Resources/en.lproj {} \; I get a lot of errors: genstrings: error: bad entry in file ./bla-bla/myfile.swift (line = 30): Argument is not a literal string. So, it seems that genstrings doesn't work with wrappers, though the man states: s routine [-s routine ...] Recognizes routine() as equivalent to NSLocalizedString(). For example, -s MyLocalString will catch calls to MyLocalString(), MyLocalStringFromTable(), and so on. Am I missing something? Is there any way to generate a strings file except looking for some better tools on GitHub/creating my own?
5
0
3.0k
Apr ’21
PHPickerViewController's navigation bar
Hi all, I'm developing an app that uses a coordinator pattern. I have a router that presents modally view controllers passed to it. It basically adds the passed view controller to the navigation controller and attaches a cancel navigation bar button. This way I have the flexibility to present any view controller either modally or push it. The problem is PHPickerViewController. It has its own "add" and "cancel" buttons which I don't how to disable. It seems that they are not in view controller's navigation bar. And doing something like this: navigationController.setViewControllers([phPickerViewController], animated: false) just adds another navigation bar on top. That looks ugly. How can I overwrite the default PHPickerViewController's "navigation bar"? // I can make a customer PHPickerViewController or, easier, a custom router for it, but that seems like a lot of custom work for such a simple thing. I'd rather make a proper configuration in coordinator...
1
0
950
Dec ’21
UISearchController prevents button tap inside UICollectionViewListCell
Good day to all, I have a weird problem with tapping on a button inside collection view cell when search results controllers is active. So, I'm initializing searchController like this: private let searchController = UISearchController(searchResultsController: nil) In my viewDidLoad(): searchController.searchResultsUpdater = self searchController.obscuresBackgroundDuringPresentation = false searchController.definesPresentationContext = true navigationItem.searchController = searchController Making data source: private func makeDataSource() -> DataSource { let cellRegistration = UICollectionView.CellRegistration( handler: CellProvider().cellRegistrationHandler ) return DataSource(collectionView: collectionView) { (collectionView: UICollectionView, indexPath: IndexPath, item: IngredientViewData) in return collectionView.dequeueConfiguredReusableCell( using: cellRegistration, for: indexPath, item: item ) } } Nothing fancy. In the CellProvider: var buttonConfiguration = addButtonConfiguration(for: item) buttonConfiguration.tintColor = .systemBlue cell.accessories = [ .customView(configuration: buttonConfiguration), .disclosureIndicator(displayed: .always) ] cell.contentConfiguration = contentConfiguration private func addButtonConfiguration(for item: IngredientViewData) -> UICellAccessory.CustomViewConfiguration { let symbolName = item.isSelected ? "checkmark.circle" : "circle" let symbolConfiguration = UIImage.SymbolConfiguration(textStyle: .title1) let image = UIImage( systemName: symbolName, withConfiguration: symbolConfiguration ) let button = AddButton() button.addTarget( nil, action: #selector(IngredientsCollectionViewController.didPressDoneButton), for: .touchUpInside ) button.id = item.id button.setImage(image, for: .normal) return UICellAccessory.CustomViewConfiguration( customView: button, placement: .leading(displayed: .always)) } Pretty basic setup. Simple button and selector to the view controller. Tapping works fine when searchController is not active. And if it is, then IngredientsCollectionViewController.didPressDoneButton won't be called. What am I missing?
0
0
341
Apr ’23