3

I have a UITextView which has a text combination of some strings and URL. Right now when I click on the URL it opens it up in safari. What I want to do instead is to have it open in a new UIViewController pushed as a modalViewController. There are two problems with this:

  1. Extracting the URL from the UITextView
  2. Intercepting the call to safari to open it up and instead push a modalViewController to display it in a webview.

I know it has been done before, for example in the tweetbot app. It opens up the link in a navigation bar where you can go back to the previous view. Something like this is also fine with me. Any pointers on what to do?

It's annoying for a user when you have to open up the link in a browser and you can't go back to the app again.

UPDATE:

I followed the suggestion given 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
aherlambang
  • 14,290
  • 50
  • 150
  • 253
  • "It's annoying for a user when you have to open up the link in a browser and you can't go back to the app again." You can, with multitasking, you just double tab the home button and navigate back to your app. – Stephan van den Heuvel May 11 '11 at 23:58
  • 1
    yes, I know.. but wouldn't it be better if you can just click one done button at the popupModalViewController – aherlambang May 12 '11 at 00:27

0 Answers0