Advertisement
khangnguyen

hijack webview

Mar 14th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // The function signature is (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
  2. // It is a delegate method webview.delegate = self
  3.  
  4. if ([request.URL.scheme isEqualToString:@"clickmedix"]) {
  5.         if ([request.URL.host isEqualToString:@"resource"]) {
  6.             NSString *path = [CMSyncDownloader absolutePathFor:request.URL.lastPathComponent];
  7.             MPMoviePlayerViewController *mpvc = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:path]];
  8.             [[NSNotificationCenter defaultCenter] addObserver:self.parentVC
  9.                                                      selector:@selector(moviePreviewFinished:)
  10.                                                          name:MPMoviePlayerPlaybackDidFinishNotification
  11.                                                        object:mpvc.moviePlayer];
  12.             [self.parentVC presentMoviePlayerViewControllerAnimated:mpvc];
  13.         }
  14.         return NO;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement