I have many SubViews in my UIView
, and many of them have UIButtons
in them. One of the subviews- _bottomView
(Coordinates- (0,519,320,49) ) has an error. It does not recognise the click events on the buttons placed inside it.
I tried placing a UIButton
covering the entire _bottomView
and the click event from that Button ( testButton
) is not being recognised either.
I tried adding a tapRecogniser to the code and the tap from every point, EXCEPT the points within the _bottomView are recognised. TapRecogniser Code below
UITapGestureRecognizer *gr = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)];
[self.view addGestureRecognizer:gr];
_bottomView.userInteractionEnabled=true;
-(void)handleGesture:(UIGestureRecognizer *)gestureRecognizer {
CGPoint p = [gestureRecognizer locationInView:self.view];
NSLog(@"got a tap in the region i care about");
}
I tried [self.view addSubview:_bottomView];
and that didn't help either. What could be the issue?
If your view is not receiving touches
UIView
has userInteractionEnabled
set to YES
NSLog(@"%@",NSStringFromCGRect(view.frame));
Nothing helped. I had to delete the entire View Controller and redo the whole thing. That obviously solved the problem.
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.