Question

I have a webview in my mainviewcontroller and i am laoding a webpage in viewdidload method as below:

- (void)viewDidLoad
{
    [super viewDidLoad];


    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

    [_loginWebView loadRequest:requestObj];


}

and in the shouldstartloadwithrequest method, i check if the url contains "itunes" and i have the following code for it:

- (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;
}

the above code works it opens the apps i desire but when I go back to my app from ipad, instead of going to the mainviewcontroller, it reopens the previous opened app. for example if I opened marketboard app, it reopens it when i tap the app icon from ipad home. But the above only happens in ios5.0, it does not happen in 6.0 which is really weird

Was it helpful?

Solution

It is the default behaviour when you have webview loadrequest in viewdidload method in ios5.0 and they have fixed it in ios6.0

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top