在另一个ViewController的UIWebView中打开UITextView中的链接

在另一个ViewController的UIWebView中打开UITextView中的链接,uiwebview,uitextview,openurl,Uiwebview,Uitextview,Openurl,好的,我正在做的项目有一个twitter提要,我把它放在一个表中,我把tweet的主要部分放在一个UITextView中。我希望它能够在UIWebView中打开文本中的链接。我使用以下命令成功地截获了openurl调用 #import "MyApplication.h" #import "haydnboardAppDelegate.h" @implementation MyApplication - (BOOL)openURL:(NSURL *)url { return [self op

好的,我正在做的项目有一个twitter提要,我把它放在一个表中,我把tweet的主要部分放在一个UITextView中。我希望它能够在UIWebView中打开文本中的链接。我使用以下命令成功地截获了openurl调用

#import "MyApplication.h"
#import "haydnboardAppDelegate.h"

@implementation MyApplication
- (BOOL)openURL:(NSURL *)url
{
   return [self openURL:url forceOpenInSafari:NO];
}


-(BOOL)openURL: (NSURL *)url forceOpenInSafari:(BOOL)forceOpenInSafari
{

    if(forceOpenInSafari)
    {
        // We're overriding our app trying to open this URL, so we'll let UIApplication     federate this request back out
        //  through the normal channels. The return value states whether or not they were able to open the URL.
        return [super openURL:url];
    }

    //
    // Otherwise, we'll see if it is a request that we should let our app open.

    BOOL couldWeOpenUrl = NO;

    NSString* scheme = [url.scheme lowercaseString];
    if([scheme compare:@"http"] == NSOrderedSame
       || [scheme compare:@"https"] == NSOrderedSame)
    {
        // TODO - Here you might also want to check for other conditions where you do not want your app opening URLs (e.g.
        //  Facebook authentication requests, OAUTH requests, etc)

        // TODO - Update the cast below with the name of your AppDelegate
        // Let's call the method you wrote on your AppDelegate to actually open the BrowserViewController
        couldWeOpenUrl = [(haydnboardAppDelegate *)self.delegate openURL:url];
    }

    if(!couldWeOpenUrl)
    {
        return [super openURL:url];
    }
    else
    {
        return YES;
    }
}
@end
我还将主.h文件更改为:

return UIApplicationMain(argc, argv, @"MyApplication", nil);
我试图在代码中调用openurl函数,但它根本不会调用该函数。当我单击TextView中的链接时,它什么也不做。我该怎么做才能让它调用函数来更改视图

编辑: 设法让我的应用程序委托中的函数运行,但当它尝试推送视图控制器时,什么也没有发生。我发现错误viewController不在窗口层次结构中,因此我决定更改该函数,以便它调用viewController中的函数,但仍然没有发生任何事情,但在viewController中调用pushViewController时没有错误消息。我发现这是因为navigationController=nil,如何解决这个问题