Open url in UITextView in modular view controller

I have a UITextView that has a text combination of some strings and URLs. Right now, when I click on the URL, it opens it in safari. Instead, I want it to be open in a new UIViewController, clicked as modalViewController. There are two problems:

  • Retrieving URLs from a UITextView
  • Intercept the safari call to open it, and instead click modalViewController to display it in the web view.

I know that this was done before, for example, in the tweetbot application. It opens a link in the navigation bar, where you can return to the previous view. Something like this is also fine with me. Any pointers to what to do?

This annoys the user when you need to open a link in a browser and you cannot return to the application again.

UPDATE:

I followed the suggestion provided in the link to this post, but after changing that, my view just changes to a white screen:

#import <Foundation/Foundation.h>

@class CVore;

@protocol CVoreDelegate

- (void) withURL:(NSURL *)url;

@end

@interface CVore : UIApplication {
    id <CVoreDelegate> delegate;
}

@property (nonatomic, assign) id <CVoreDelegate> delegate;

@end


#import "CVore.h"


@implementation CVore
@synthesize delegate;

- (BOOL)openURL:(NSURL *)url{
    if (url){
        [self.delegate withURL:url];
        return YES;
    }
    return NO;
}
@end
+3
source share

All Articles