Search code examples
iphoneiosnsstringuitextviewdatadetectortypes

UITextview dataDetectorTypeAddress - Map opened in different application


I just came to know about an awesome ios feature for UITextViews i.e UITextview dataDetectorTypes. It is really useful to display text as links.

However, I noticed one thing. When the string is a physical address, Google Map is opened which is appropriate, but in a different application.

Is there any way we can open that google map in our application and not go into default iOS application wherein map is opened? So that I can go back into my application from the map. Is there any delegate method which can control this? Right now I have to minimize the application(make it run in background) and again open it which does not looks good.


Solution

  • You should use another solution for your problem.

    If you use dataDetectorTypes, the link is alway opened in built-in app firstly.

    You can make your action with button and custom string as below:

    • push your text into an UIButton.

    • make your text displayed as link with NSAtributedSring as this question, use UIButton instead of UITextView:

    Underline text inside uitextview

    • make action for your button when user click on it.

    Good luck!