The problem is this line:
self.overlayView.frame = self.cameraOverlayView.frame;
Our cameraOverlayView
is nil; it has no frame, because it doesn't even exist yet. So we are giving the overlayView
a zero frame. It is dimensionless. The button appears, but it has a zero-sized superview and therefore cannot be tapped.
Now, you may ask, why is that? It's because of the way touch delivery works in iOS. To be touchable, a subview's superview must also be touchable, because the superview is hit-tested for the touch before the subview. But a zero-size view is not touchable: your touch misses the overlayView
, so it misses the button as well.
The solution might be as simple as giving the overlayView
a reasonable real frame. There may also be timing problems about when you do that (e.g. it may be that you cannot really set the frame until the image picker is about to appear - viewWillAppear:
), but in any case this is the place to start.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…