Andreas Jost
11/26/2019, 10:20 AMactual fun ViewContainer.setOnCLickListener(block: () -> Unit) {
val funRef = StableRef.create(InvokeClickListener(block))
this.addGestureRecognizer(UITapGestureRecognizer(this, funRef.asCPointer()))
}
class InvokeClickListener(private val block: () -> Unit) : () -> Unit {
override operator fun invoke() {
block()
}
}
I already managed to set the visibility of Views in the common code. If interested I can post code snippets in the multiplatform channel. But this case is harder, because UITapGestureRecognizer wants a selector/COpaquePointer and I can't find a solution.
Error: 'NSInvalidArgumentException', reason: '(null): unrecognized selector sent to instance 0x7f9da94c0a00'
Thanks in advance!Artyom Degtyarev [JB]
11/26/2019, 11:58 AMAndreas Jost
11/26/2019, 12:08 PMprivate fun UIView.setOnCLickListenerActual(block: () -> Unit) {
this.addGestureRecognizer(UITapGestureRecognizer(Target(block), NSSelectorFromString("invokeBlock")))
}
@ExportObjCClass
class Target(private val block: () -> Unit) {
@ObjCAction
fun invokeBlock() {
block()
}
}
Artyom Degtyarev [JB]
11/26/2019, 12:14 PMTagret
from the NSObject
, please try it if something will go wrong.Andreas Jost
11/26/2019, 12:53 PMMatthew Kruk
04/14/2022, 8:22 PMval tap = UITapGestureRecognizer(
target = this,
action = NSSelectorFromString("Tapped")
)
tap.delegate = this
tap.numberOfTapsRequired = 1u
this.addGestureRecognizer(tap)
this.setUserInteractionEnabled(true)
@ObjCAction
private fun Tapped() {
notifyClicked()
}
Class _PathPoint is implemented in both
~filepath~/TextInputUI.framework/TextInputUI (0x14acda6b8). One of the two will be used. Which one is undefined.
I've searched the error and I could only find articles calling it logging noise. Any implementation examples of a tapGesture on a UIView would be greatly appreciated :)override fun gestureRecognizer(
gestureRecognizer: UIGestureRecognizer,
shouldRecognizeSimultaneouslyWithGestureRecognizer: UIGestureRecognizer
): Boolean {
return true
}