I'm trying to override my application's openURL method to intercept link clicks in a UITextView. The UITextView is in a navigation based DetailViewController, and when the user clicks the link, I want to push a web view onto the navigation stack.
I verified that my method is being called by logging the intercepted url to the console, but the navigation controller is not pushing my WebViewController at all. I made a button in interface builder and added it onto the same view with the textview just to verify the WebView gets pushed. The button was just for testing purposes.
The problem seems that the navigationController pushViewController code isn't getting fired when I call the method from the AppDelegate, even though the NSLog shows I'm getting the valid intercepted url.
I appreciate any help offered! Code:
Inside AppDelegate.m:
DetailViewController.h:
DetailViewController.m:
I verified that my method is being called by logging the intercepted url to the console, but the navigation controller is not pushing my WebViewController at all. I made a button in interface builder and added it onto the same view with the textview just to verify the WebView gets pushed. The button was just for testing purposes.
The problem seems that the navigationController pushViewController code isn't getting fired when I call the method from the AppDelegate, even though the NSLog shows I'm getting the valid intercepted url.
I appreciate any help offered! Code:
Inside AppDelegate.m:
Code:
- (BOOL)openURL:(NSURL *)url
{
DetailViewController *detailView = [[DetailViewController alloc]init];
detailView.url = url;
[detailView push];
return YES;
}
DetailViewController.h:
Code:
#import <UIKit/UIKit.h>
@interface DetailViewController : UIViewController <UIGestureRecognizerDelegate>
@property (nonatomic, strong) NSURL *url;
- (void)push;
@end
DetailViewController.m:
Code:
- (void)push
{
WebViewController *webView = [[WebViewController alloc] initWithNibName:@"WebViewController" bundle:[NSBundle mainBundle]];
webView.url = self.url;
NSLog(@"%@",self.url);
[self.navigationController pushViewController:webView animated:YES];
}
Last edited: