Determine file extension on tap and push view controlelr

Programming
Tutor: None Selected Time limit: 3 Days

Basically I need to know how a webview knows what kind of file extension is being tapped, (png, zip, etc) and then push another view controller. So far I have this.

UPDATE 6/13 - I have updated my code per what Hunter has suggested, yet it still only opens the png, instead of pushing the vc.

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

       

        if(navigationType == UIWebViewNavigationTypeLinkClicked) {

            NSURL *theRessourcesURL = [request URL];

            NSString *fileExtension = [theRessourcesURL pathExtension];

            if ([fileExtension isEqualToString:@"png"]) {

               

                MYViewController *vc = [[MYViewController alloc] init];

                [dlvc downloadURL:theRessourcesURL userInfo:nil];

                [self.navigationController pushViewController:vc animated:YES];

               

                vc.delegate = self;

            }            

            else{}

        }      

        return YES;

    }

I have tried this before without the file extension code and it will push another view just fine.

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

        if(navigationType == UIWebViewNavigationTypeLinkClicked) {

            NSURL *theRessourcesURL = [request URL];

   

   

            DetailViewController *vc = [[DetailViewController alloc] init];

            [vc downloadURL:theRessourcesURL userInfo:nil];

            [self.navigationController pushViewController:vc animated:YES];

   

            vc.delegate = self;

   

        }

   

        return YES;

    }

I also tried to use this as a starter base without success, as I don't use interface builder, so I don't know if IBActions can be used (if they can I dont know how to implement them properly). http://stackoverflow.com/questions/7377565/how-to-download-files-from-uiwebview-and-open-again

Any help would be appreciated.


Nov 30th, -0001
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

UIViewController *viewController1 = [[DemoFirstViewController alloc] initWithNibName:@"DemoFirstViewController" bundle:nil];
UIViewController *viewController2 = [[DemoSecondViewController alloc] initWithNibName:@"DemoSecondViewController" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[viewController1, viewController2];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = navigationController;

(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

UIViewController *viewController1 = [[DemoFirstViewController alloc] initWithNibName:@"DemoFirstViewController" bundle:nil];

// here I create a Navigation Controller and set its root view controller to viewController1
UINavigationController *navController1 = [[UINavigationController alloc] initWithRootViewController:viewController1];

UIViewController *viewController2 = [[DemoSecondViewController alloc] initWithNibName:@"DemoSecondViewController" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];

// updated this line to show the navController1 (which contains viewController1)
self.tabBarController.viewControllers = @[navController1, viewController2];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
Jun 14th, 2013

Did you know? You can earn $20 for every friend you invite to Studypool!
Click here to
Refer a Friend
...
Nov 30th, -0001
...
Nov 30th, -0001
Dec 9th, 2016
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer