-2

I'm using a delegate UITabbarController with transition animation like this:

-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {

    NSArray *tabViewControllers = tabBarController.viewControllers;
    UIView * fromView = tabBarController.selectedViewController.view;
    UIView * toView = viewController.view;
    if (fromView == toView)
        return TRUE;
    NSUInteger fromIndex = [tabViewControllers indexOfObject:tabBarController.selectedViewController];
    NSUInteger toIndex = [tabViewControllers indexOfObject:viewController];

    [UIView transitionFromView:fromView
                    toView:toView
                  duration:0.3
                   options: toIndex > fromIndex ? UIViewAnimationOptionTransitionFlipFromLeft : UIViewAnimationOptionTransitionFlipFromRight
                completion:^(BOOL finished) {
                    if (finished) {
                        tabBarController.selectedIndex = toIndex;
                    }
    }];
    return true;
}

Only this broke my entire ViewDidAppear on the views. I'm resetting the UIWebView to the homepage when switching between tabs, but this doesn't work anymore. Any suggestions? Here's my VieDidLoad:

-(void)viewDidAppear:(BOOL)animated{

    [super viewDidAppear:animated];
    _progressProxy = [[NJKWebViewProgress alloc] init];
    _webView.delegate = _progressProxy;
    _progressProxy.webViewProxyDelegate = self;
    _progressProxy.progressDelegate = self;

    [self loadSite];
    [TestFlight passCheckpoint:@"Bekijkt homepage"];
}

[self loadSite]; is defined as:

-(void)loadSite
{
    NSString *dealerurl = [[NSUserDefaults standardUserDefaults] stringForKey:@"name_preference"];
    NSString *urlAddress= @"http://www.sportdirect.com/shop/";
    NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlAddress]];
    [_webView loadRequest:req];
    [[_webView scrollView] setBounces: NO];
}

Thanks in advance.

Joran Den Houting
  • 3,149
  • 3
  • 21
  • 51
  • 1
    your code looks OK, set a Breakoint in viewDidAppear and try to replace your viewDidAppear methode with viewWillAppear – David Gölzhäuser Oct 25 '13 at 08:58
  • 2
    @DavidG. Turns out it actually reaches the breakpoint set on `self loadsite` every switch.. It's just not changing the `UIWeview`.. – Joran Den Houting Oct 25 '13 at 09:07
  • OK, set a breakpoint at the first line of -(void)loadSite, and check values, check if something is nil. And I would add this methode to recognize if the webView did fail to load: - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { NSLog(@"Error"); } – David Gölzhäuser Oct 25 '13 at 09:09
  • `_webView UIWebView * nil 0x00000000` _webView is... How to get rid of it? – Joran Den Houting Oct 25 '13 at 09:13
  • When will that error occur? I would recogmend to replace all _propertyNamen with self.propertyName, like replacing _webView with self.webView – David Gölzhäuser Oct 25 '13 at 09:16

1 Answers1

1

Change:

[_webView loadRequest:req];

to this:

self.webView loadRequest:req;

I think this will undo the nil.