2

I've had a crash report, it's a real edge case. I launch a pin security view from applicationWillEnterForeground (the feature is optional). However, I have some form sheets which I use in some situations in my app.

So the pin view is added as a subview on window and a keypad is presented.

When the form sheet is showing, it appears on top of the pin view (which is wrong) and an action on the form sheet causes a crash, when showing another keypad.

So I believe I need to dismiss any form sheets if the application resigns / becomes active.

I've looked into sending a notification to the form sheet in applicationWillEnterForeground, however I'll have to firstly determine if a form sheet is visible then add method to dismiss it every form sheet.

This seems a lot of work for an edge case, can anyone suggest an alternative approach?

For completeness here's the error...

The layout constraints still need update after sending -updateConstraints to <_UIKeyboardLayoutAlignmentView: 0x14e59b790; frame = (0 0; 0 0); userInteractionEnabled = NO; layer = >. _UIKeyboardLayoutAlignmentView or one of its superclasses may have overridden -updateConstraints without calling super. Or, something may have dirtied layout constraints in the middle of updating them. Both are programming errors.

I've seen this... NSInteralInconsistencyException - UIKeyboardLayoutAlignmentView

However, I'd still need to end editing in various form sheets, which I can't access from applicationWillEnterForeground.

Community
  • 1
  • 1
Jules
  • 7,568
  • 14
  • 102
  • 186

1 Answers1

0

OK, after researching the issue I discovered that I needed to observe the application state. On notification then check if various objects are load and if so, resignFirstResponder when the keyboard is shown (aka is editing) (I had a text field in an UIAlertView), dismiss an UIAlertView and then dismiss in the view controller used in dialog.

Shesh... so not as simple as I was hoping. Although this is an edge case for me, I figured I should fix it.

I also found this which will dissmiss alertviews https://github.com/sdarlington/WSLViewAutoDismiss

Which will save me a lot of hassle in simpler scenarios.

Apparently since iOS4, Apple recommends cancelling UIAlertViews and UIActionSheets when an application becomes active.

Jules
  • 7,568
  • 14
  • 102
  • 186