I've got a custom alert view, which appears in its own UIWindow
with its windowLevel
property set to UIWindowLevelAlert
. The alert has a text field with a regular keyboard, and a custom UIControl
subclass that returns a UIDatePicker
as its inputView
.
When the system presents the date picker in response to the control becoming first responder, the date picker appears behind the alert view. My solution to this was to adjust the picker's window's window level in the control's reloadInputViews
:
- (void)reloadInputViews
{
[super reloadInputViews];
if (self.datePicker.window.windowLevel < self.window.windowLevel)
{
self.datePicker.window.windowLevel = self.window.windowLevel;
}
}
The problem is that the app freezes when rapidly switching between the text field and the custom control (pausing the debugger reveals that the main thread is stuck on mach_msg_trap
). I suspect that maybe its this trick with the window level, but I cannot verify.
Is there a more "correct" way to solve this problem? What is mach_msg_trap?
Thanks!