Initial layout is caught in animation block when keyboard frame change is triggered when a view in a form sheet will appearing

Originator:douglashill
Number:rdar://24135531 Date Originated:11-Jan-2016 09:05 PM
Status:Open Resolved:
Product:iOS SDK Product Version:
Classification: Reproducible:
 
Summary:
When a text field in a form sheet becomes or resigns first responder in `viewWillAppear:`, the initial view layout is caught in the animation block that moves the form sheet up or down. 

A sample project is attached that demonstrates the problem when becoming first responder (keyboard appearing). The case of resigning first responder is possibly worse because this is handled automatically by UIKit when a view disappears.

Steps to Reproduce:
Run the attached sample project full screen on iPad (regular or Pro, simulator or device) on iOS 9.

Page one (a cyan view) is presented in a form sheet.

Tap the cyan view to push page two, which has a text field that becomes first responder in `viewWillAppear:`.

Expected Results:
The initial view layout should not be animated. Page two should be laid out as soon as it appears.

Actual Results:
The elements on page two animate when they appear, popping from the top of the view. A dark grey view is provided to make this easier to see.

Version:
iOS 9.2 (13C75)

Notes:
Regression: does not happen on iOS 8.3, so appears to have been introduced in iOS 9.

Does not happen in compact widths where the form sheet is full screen.

Workaround: Become first responder in a `dispatch_async` block. Yuck. Maybe something similar can be done for resigning first responder when disappear but I have not tried yet.

Configuration:
iPad Air

Attachments:
'LayoutAnimation.zip' was successfully uploaded.

Comments

https://www.dropbox.com/s/py36gnpdi5hg5gz/LayoutAnimation%2024135531.zip?dl=0

By douglashill at Jan. 11, 2016, 9:08 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!