[英]Setting a Button with an image in the AccessoryView
I would like to customize the image in the accessory views of some tables while allowing to pass the table and indexPath to the accessoryButtonTappedForRowWithIndexPath callback including the clicked table. 我想在某些表的附件视图中自定义图像,同时允许将表和indexPath传递给包括clicked表在内的annexButtonTappedForRowWithIndexPath回调。 I used to employ the UIControl+Blocks.h class here reported:
我曾经在这里报道过使用UIControl + Blocks.h类:
@implementation UIControl (Blocks)
- (void)addEventHandler:(ActionBlock)handler forControlEvents: (UIControlEvents)controlEvents
{
objc_setAssociatedObject(self, &UIButtonHandlerKey, handler, OBJC_ASSOCIATION_COPY_NONATOMIC);
[self addTarget:self action:@selector(callActionHandler:event:) forControlEvents:controlEvents];
}
- (void)callActionHandler:(id)sender event:(id)event
{
ActionBlock handler = (ActionBlock)objc_getAssociatedObject(self, &UIButtonHandlerKey);
if (handler) {
handler(sender, event);
}
}
@end
But it started behaving weirdly by sometimes returning the button in the place of the event so crashing my app when I try to get allTouches and so I am fervidly looking for a replacement. 但是它有时表现得很奇怪,有时会在事件发生的地方返回该按钮,因此当我尝试获取allTouches时,我的应用程序崩溃了,因此我很想寻找一个替代品。
I also tried replacing the original (i) accessory button, but in this way I also lose the accessibilityLabel. 我还尝试更换了原始(i)附件按钮,但是这样我也失去了accessibilityLabel。 Please help.
请帮忙。
我预见到了表重新加载的问题,从而恢复了旧的解决方案,以防按钮发疯并开始将自身发送为控件事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.