Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error on TextView with detection phone number IOS 9

Tags:

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?

like image 824
Anibal Lamego Avatar asked Sep 18 '15 13:09

Anibal Lamego


1 Answers

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.

like image 123
mourlam Avatar answered Oct 15 '22 22:10

mourlam