在iOS中获取UIGestureRecognizer的 *** 作

在iOS中获取UIGestureRecognizer的 *** 作,第1张

概述我在NSLog中的 – tableView:didSelectRowAtIndexPath方法中打印了一个UITableviewCell的手势 <UIScrollViewPanGestureRecognizer: 0x11e92080; state = Possible; cancelsTouchesInView = NO; delaysTouchesEnded = NO; view = <UIT 我在NSLog中的 – tableVIEw:dIDSelectRowAtIndexPath方法中打印了一个UItablevIEwCell的手势
<UIScrollVIEwPanGestureRecognizer: 0x11e92080; state = Possible; cancelstouchesInVIEw = NO; delaystouchesEnded = NO; vIEw = <UItableVIEwCellScrollVIEw 0x11e94bf0>; target= <(action=handlePan:,target=<UItableVIEwCellScrollVIEw 0x11e94bf0>)>>

我已将此UIScrollVIEwPanGestureRecognizer分配给UIGestureRecognizer以访问其属性,如下所示,

UIGestureRecognizer *myGes=[temp.gestureRecognizers objectAtIndex:1];

我能够访问’myGes’的所有属性

myGes.state; myGes.cancelstouchesInVIEw; myGes.delaystouchesEnded; myGes.vIEw;

除了一个名为target的属性.

有没有可能访问该属性?因为我需要执行该 *** 作.

任何意见或建议将不胜感激.

先感谢您.

解决方法 有一种方法可以访问属性目标,但我不确定此方法是否会通过Apple批准过程.
NSMutableArray *targets = [myGes valueForKeyPath:@"_targets"];ID targetContainer = targets[0];//get first target for exampleID targetofMyGes = [targetContainer valueForKeyPath:@"_target"];NSLog(@"%@",targetofMyGes );//you can see reference for target object

谢谢neilco – 他的回答有助于创建解决方案.

注意:对象targetofMyGes的确切类需要自己定义.默认情况下,它ID – 适用于任何对象类.

总结

以上是内存溢出为你收集整理的在iOS中获取UIGestureRecognizer的 *** 作全部内容,希望文章能够帮你解决在iOS中获取UIGestureRecognizer的 *** 作所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1104799.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存