質問

I have tried this a few different ways but none of them seem to work. I have a UIView subclass that has some buttons in it. I tried adding the subview to my ViewControllers however it will not respond to touches unless I set it to "initWithFrame:self.view.frame" but then it takes All of the touches and does not pass them to the view controller. I also tried adding it directly to the window so it's on top of all of the view however I have the same issue, either it will not accept touches or it takes them all.

here is how I add it when it takes all touches for itself and does not pass them on.

ControlView *cont = [[ControlView alloc]initWithFrame:self.window.frame];
[self.window addSubview:cont];

I'm so confused as to how to fix this and I have a lot more important tasks to work on but I have been stuck for two days with this stupid subview/touch issue.

役に立ちましたか?

解決

How are you handling touches? UIGestureRecognizer?

You should make sure that your uiview subclass has userInteractionEnabled = YES. That's the default but maybe it got turned off somewhere along the line.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top