Action sheets presented for links don’t work in presented view controllers

Number:rdar://26294823 Date Originated:16-May-2016 05:42 PM
Status:Open Resolved:
Product:iOS SDK Product Version:
Classification: Reproducible:Always
Action sheets presented by links in UITextView, UIWebView and WKWebView don’t work if there is a presented view controller. UIKit and WebKit both attempt to present these alert controllers on the root view controller, which fails and logs a message to the console if the root view controller already has a presented view controller.

Steps to Reproduce:
1. Present a view controller whose view hierarchy contains a UITextView, UIWebView or WKWebView containing links.
2. Try to trigger an action sheet from a link, for example by long pressing on a web link or tapping on a detected calendar event link.

You can observe this problem running the attached sample project on any iOS device or simulator with iOS 8 or later. The project demonstrates the problem in each of UITextView, UIWebView and WKWebView in three tabs. In the project try interacting with the links on the first screens (in the tabbed bar) and on the second screens (presented view controllers shown by tapping the button in the top right).

Expected Results:
An action sheet should be presented.

UIKit and WebView should try to present the alert controller on the correct view controller.

Actual Results:
When there is a presented view controller on the window’s root view controller (on the second screens in the sample project) action sheets are not shown. Instead, a message is logged about presenting on a view controller’s whose view is not in the window hierarchy or about already presenting if the presentation is not full screen (depending on modal presentation style).

iOS 9.3.1 (13E238) Xcode 7.3.1

The UIKit bug appears to be in -[_UIRotatingAlertController presentSheetFromRect:]. It starts from the view that triggered the action. It takes that view’s window, then the window’s root view controller and presents on that.

WebKit does the same thing:

It seems likely this bug was copy/pasted from one codebase to the other.

iPhone 5S

'' was successfully uploaded.


By douglashill at May 16, 2016, 8:55 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at 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!