Question

Please have a look at the following code

-(void)viewDidLoad{
    self.viewControllers = [NSMutableArray arrayWithCapacity:0];
    UIViewController* controller = nil;

    controller = [[aViewController alloc]initWithNibName:@"aViewController" bundle:nil];
    controller.view.frame = CGRectMake(1024*0, 0, 1024, 768);
    [scrollView1 addSubview:controller.view];   
    [viewControllers addObject:controller];

    controller = [[bViewController alloc]initWithNibName:@"bViewController" bundle:nil];
    controller.view.frame = CGRectMake(1024*1, 0, 1024, 768);
    [scrollView1 addSubview:controller.view];   
    [viewControllers addObject:controller];

    controller = [[cViewController alloc]initWithNibName:@"cViewController" bundle:nil];
    controller.view.frame = CGRectMake(1024*2, 0, 1024, 768);
    [scrollView1 addSubview:controller.view];
    [viewControllers addObject:controller];

}

I visit the bViewController now, and I want to show an alert when I leave the bViewController, but the viewDidUnload doesn't work.

The - (void)viewWillDisappear:(BOOL)animated doesn't work either.

So which can work?

Was it helpful?

Solution

I can suggest to show an alert into scrollViewDidScroll: method when scrollView.contentOffset.x < 1024.0f.

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