2013-01-23 21 views
0

我在mainviewcontroller網頁視圖,我貼膜在如下viewDidLoad方法網頁:iOS應用擊中直線shouldstartloadwithrequest從背景的後代替

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 


    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 

    [_loginWebView loadRequest:requestObj]; 


} 

,並在shouldstartloadwithrequest方法,我檢查網址包括「iTunes的」和我有它下面的代碼:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{ 


NSRange textRange4; 
      textRange4 =[[[request URL] absoluteString] rangeOfString:@"itunes.apple.com"]; 
      if(textRange4.location != NSNotFound) 
      { 

       UIApplication *app = [UIApplication sharedApplication]; 
       NSString *newPath = [[request URL] absoluteString] ; 

       if ([newPath rangeOfString:@"insider"].location != NSNotFound) { 
        NSURL *myURL = [NSURL URLWithString:@"insider://"]; 
        if ([app canOpenURL:myURL]) { 
         [app openURL:myURL]; 
         NSLog(@"insider"); 

        } 
        else 
        { 
         [app openURL:[NSURL URLWithString:newPath]]; 
        } 


       } 
       else if ([newPath rangeOfString:@"reuters-news-pro-for-ipad"].location != NSNotFound) { 

         [app openURL:[NSURL URLWithString:newPath]]; 

       } 
       else if ([newPath rangeOfString:@"thomson-reuters-marketboard"].location != NSNotFound) { 
        NSURL *myURL = [NSURL URLWithString:@"marketboard://"]; 
        if ([app canOpenURL:myURL]) { 
         [app openURL:myURL]; 
         NSLog(@"marketboard"); 
        } 
        else 
        { 
         [app openURL:[NSURL URLWithString:newPath]]; 
        } 


       } 
       else 
       { 
        [app openURL:[NSURL URLWithString:newPath]]; 

       } 

       return NO; 

      } 
return YES; 
} 

在上面的代碼工作它打開我想要的應用程序,但是當我回到從iPad上我的應用程序,而不是去到mainviewcontroller,重新開放之前打開的應用程序。例如,如果我打開marketboard應用程序,它會在我點擊ipad home的應用程序圖標時重新打開它。 但上面只發生在ios5.0,它不會在6.0這是很奇怪

回答

0

這是當你有viewDidLoad方法的WebView中的loadRequest ios5.0 默認行爲,以及他們在iOS6的有固定的發生.0