0

In a collectionView, I'm using several textFields with different issues. All have an "extended keyboard" with custom UIBarButtons. As I need to reuse it a lot, I solved my problem with using an extension, quite similar to this one : https://stackoverflow.com/a/31010668/8162027.

My buttons are always the same: "cancel" and "Done". But the func linked must return different things. Is there a way to override those @objc func for these 2 buttons donePressed() and cancelPressed() from my UIcollectionView?

Here is a screenshot of my buttons:

https://i.stack.imgur.com/OuHNS.jpg

Rodrigo Morbach
  • 378
  • 4
  • 16
Creanomy
  • 216
  • 2
  • 12
  • Your `donePressed()` and `cancelPressed()` must return values? – Rodrigo Morbach Jan 25 '19 at 00:37
  • Essentially my done button : endEditing the actual TF and the most important : reloadData at specific indexPath – Creanomy Jan 25 '19 at 00:46
  • Any suggestion ? – Creanomy Jan 25 '19 at 18:40
  • Maybe you can create a protocol, with these two methods `donePressed` and `cancelPressed`, and your extension `addToolBar` could receive an implementation of such protocol, which could be your `UICollectionView`, for example. – Rodrigo Morbach Jan 30 '19 at 13:18
  • Thanks @RodrigoMorbach... I'll manage in that way. it seems to be a bit tricky, but i'll try. – Creanomy Feb 01 '19 at 19:14
  • Yes, it is a bit tricky. It is hard to tell without seem the code. Another possible solution would be the `ViewController` that owns the `collectionView`, overriding both `donePressed` and `cancelPressed` methods. – Rodrigo Morbach Feb 04 '19 at 12:23

0 Answers0