Guest User

Untitled

a guest
Apr 20th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. UINavigationController* classesNav = (UINavigationController*)self.tabBarController.viewControllers[4];
  2. BuyCredit *classesViewController = [classesNav.viewControllers firstObject];
  3. [classesViewController fromClassBook:sURL];
  4.  
  5. UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
  6. UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"BuyCredit"];
  7. vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
  8. [self presentViewController:vc animated:YES completion:NULL];
  9.  
  10. - (void)viewDidLoad {
  11.  
  12. [super viewDidLoad];
  13.  
  14. sURL = self.urlString;
  15.  
  16. NSLog(@"Receiving From and the sURL : %@", sURL);
  17.  
  18. NSURL *url = [NSURL URLWithString:sURL];
  19. NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
  20. [webView setDelegate:(id<UIWebViewDelegate>)self];
  21. [webView loadRequest:urlRequest];
  22.  
  23. }
  24.  
  25. - (void)fromClassBook:(NSString*)string {
  26.  
  27. sURL = string;
  28. NSLog(@"Please pass over **** %@", sURL);
  29.  
  30. NSURL *url = [NSURL URLWithString:sURL];
  31. NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
  32. [webView setDelegate:(id<UIWebViewDelegate>)self];
  33. [webView loadRequest:urlRequest];
  34.  
  35. }
  36.  
  37.  
  38. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  39.  
  40. PurchaseDet *target = segue.destinationViewController;
  41.  
  42. if ([segue.identifier isEqualToString:@"PurchaseDet"]) {
  43.  
  44. target.urlString = sURL;
  45.  
  46. }
  47. }
  48.  
  49.  
  50. - (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
  51.  
  52. NSURL *URL = [request URL];
  53. NSString *theString = [URL absoluteString];
  54. NSRange match;
  55.  
  56. NSLog(@"Detect the URL theString : %@", theString);
  57.  
  58. match = [theString rangeOfString: @"PHPSMI"];
  59.  
  60. //--- If the URL string does not contain purchase_det.asp meaning it will load the webview
  61. if (match.location == NSNotFound) {
  62. sURL = theString;
  63. return YES; //--- Load webview
  64.  
  65. } else { //--- Because currently the purchase confirm page is just another page, hence will reload the current webview.
  66.  
  67. NSLog(@"Will pass to SEQUE and called the URL :%@",theString);
  68. //--- Calling this method will tell the segue hey I want to redirect to another viewController.
  69. //--- Update the sURL with the latest String
  70. sURL = theString;
  71.  
  72. [self performSegueWithIdentifier:@"PurchaseDet" sender:self];
  73.  
  74. return NO; // Don't load the webview, capture the sURL and trigger NewsDet segue, and then pass sURL as urlstring to destination VC
  75. }
  76.  
  77. }
  78. @end
Add Comment
Please, Sign In to add comment