简体   繁体   中英

Button on a UITableviewCell's subview does not respond

I am implement a scorllable UITableview Cell and I get into a problem:

On the common tableview cell, I added a scrollview . On that scrollview , I added another cell called socialcell . I know it's weird to add a cell to another cell, but it doesn't matter and you can just take it as a view. On the socialcell , there is a button . The problem is that the button can't receive any touch event, and the touch is received by the tableview.

It's been checked that all of the views were added to their parent view correctly.

I have viewed the UI hierarchy and the button is right on the top. Is it the problem of iOS?

Thanks in advance!

I have just solved the problem, thanks to anyone who tried to help!

This is how I solved the problem:

It seems that the scrollview distracts the touch events of other views, and I override a function of scrollview :

-(id)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
id hitView = [super hitTest:point withEvent:event];
if (hitView == self) return nil;
else return hitView;}

And it did work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM