20

I'm testing my app on an iPod Touch running iOS 9 (on iOS 8.4 it was working for other functions: FaceTime, copy to contacts, etc.). I have a textview with phone number detection and I receive the following error:

Warning: Attempt to present <_UIRotatingAlertController: 0x16250e00> on whose view is not in the window hierarchy!

Assertion failure in -[UITextView startInteractionWithLinkAtPoint:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3505.16/UITextView_LinkInteraction.m:377

Any fix to this?

Charlie Schliesser
  • 7,851
  • 4
  • 46
  • 76
Anibal Lamego
  • 241
  • 1
  • 8

2 Answers2

2

Not a perfect solution but very simple and may help a desperate developer:

- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange {
    [[UIApplication sharedApplication] openURL:URL];

    return NO;
}

You will lose the Copy, Open URL, Cancel popover on long press but you SHOULD at least be able to open url same as you would previously. In iOS 9, this still opens a browser window inside your app for standard URLs (which is nice).

This seems like an Apple bug (posted to radar already).

We were seeing very similar error when trying to open links in a modal view since Apple is trying to display a new modal alert view. Outside of modal view data detection worked just fine in iOS 9 for us.

mourlam
  • 81
  • 5
1

This looks quite similar to a bug we recently had to fix for PSPDFKit where presenting sheets did not work when the rootViewController was already presenting another controller. (Is your rootViewController maybe not set?)

You can read the source code here. This might help you to figure out where the issue is for you:

https://gist.github.com/steipete/b00fc02aa9f1c66c11d0f996b1ba1265

And please dupe rdar://26295020 so this will get hopefully fixed in time for iOS 10. (The bug exists since iOS 8 and was first reported on iOS 8b5.)

steipete
  • 7,581
  • 5
  • 47
  • 81