0

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!

Austin
  • 5,625
  • 1
  • 29
  • 43

1 Answers1

0

As so often happens, I figured it out shortly after posting...

As the mach_msg_trap instruction hints, this was a threading issue, unrelated to the implementation of the date picker control.

I fixed some NSLock objects elsewhere, which seems to have resolved the issue.

Austin
  • 5,625
  • 1
  • 29
  • 43