I can\'t figure out why tapping on text fields and buttons in my view is not working. I\'ve checked all the obvious things like whether userInteractionEnabled is set to YES, whe
You can subclass UIWindow
and override -[UIWindow sendEvent]:
, then when it is called, use -[UIWindow hitTest:withEvent:]
to test which view will receive the event.
You can then call -[UIView recursiveDescription]
to print some debug information help you understand why that view received the touch event.
Remember to call [super sendEvent:]
when you are done.
For those who use Storyboard and want to know how can we change the main application window class:
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow? = TestWindow()
// ....
}
Just provide the default value for AppDelegate
's window
var. When the app is launched the UIApplicationMain
will instantiate a delegate and ask it for the window
. If the window
is nil
it will create a new one automatically. But if we provide a default value here, it will be used all over the app.