WKWebView does not present action sheets on current controller

Originator:futuretap
Number:rdar://24134661 Date Originated:11-Jan-2016 09:15 PM
Status:Duplicate/18110831/Open Resolved:
Product:iOS SDK Product Version:9.2
Classification:UI/Usability Reproducible:Always
 
This is a duplicate of rdar://18110831

Summary:
When using the new WKWebView class, if it is presented in a modal fashion, any long pressed links will not show the action sheet for choosing options as to how to handle the link. Instead, a message like the following is generated, "Warning: Attempt to present <WKActionSheet: 0x7fcd60572d10> on <ViewController: 0x7fcd60522c10> whose view is not in the window hierarchy!"

On iPad, if this happens and then a user rotates, the modal view is abruptly dismissed.

Steps to Reproduce:
0. Run the attached application.
1. Press the "Show Web View" button, and wait for the page to load
2. Long press on any element
(3.) if on iPad, rotate.

Expected Results:
The action sheet with options for link handling is correctly displayed. And if the device is an iPad, it rotates correctly without dismissing the content.

Actual Results:
No action sheet is presented on iPhone or iPad, however, the following message is generated, "Warning: Attempt to present <WKActionSheet: 0x7fcd60572d10> on <ViewController: 0x7fcd60522c10> whose view is not in the window hierarchy!". If the user is on an iPad and has rotated, the entire modal view controller is removed from the view hierarchy.

Version:
iOS 8 Beta 5

Notes:


Configuration:
iPhone 5 64GB AT&T

Attachments:
'webkittest.zip' was successfully uploaded.

Comments

Also results in crash

If you then proceed dismiss the modal/presented view containing the WKWebView and then rotate, the app will crash.

By isaac.schmidt at Feb. 12, 2016, 10:14 p.m. (reply...)

Workaround

Apparently, the view controller is presented from the root view controller, not the nearest one with definesPresentationContext. So it helps to redirect the presentation from the root view controller:

http://stackoverflow.com/a/29929312/235297


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!