Iphone SDK - Preview Animation

I have a view that has a UIWebView and a options panel (a custom UIViewController with a custom view).

I want, when the view is displayed, for the options bar (located at the top of the main view), so that FLIP snaps into place. I use code and I get a weird result.

The first time the view is displayed, the options bar seems already visible ... When I click BACK on my navController and pull the View again, the animation works fine.

Can someone shed some light on this topic?

- (void)viewDidLoad {
    [super viewDidLoad];
    optionsPane=[[OptionsPaneController alloc] initWithNibName:@"OptionsPane" bundle:nil];
}

- (void)viewWillAppear:(BOOL)animated {

    [optionsPane.view removeFromSuperview];
    [self checkOptionsVisible];
}

-(void)checkOptionsVisible{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:[optionsPane view] cache:YES];
    [[self view] addSubview:[optionsPane view]];
    [theWebView setFrame:CGRectMake(0,87,320,230)];
    [[optionsPane view] setFrame:CGRectMake(0,0,320,87)];
    [UIView commitAnimations];      
}
+3
source share
4 answers

, , .

, , viewDidLoad. nib , viewWillAppear.

, , - , viewWillApper .

viewDidLoad , viewWillAppear .

?
, "viewDidAppear". , , .

(, ) - checkOptionsVisible viewDidLoad.
, - .

, .

0

, , viewWillAppear . , SDK. , , :

. , , , . , . , .

, , viewWillAppear , .

+1

:

:

  • ( ) 100

  • ( ) 100

.

, , .

, .

, , , .


3 :

2, . . backingViewController:

- (void)displayBack{

    //parent controller is an ivar so the sub-view controllers know who their daddy is
    backController.parentController = self;


    [UIView beginAnimations:nil context:@"flipTransitionToBack"];
    [UIView setAnimationDuration:1.2];

    //note self.view IS the backing view
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];

    //remove the front view
    [[frontController view] removeFromSuperview];
    //add the back view view
    [self.view addSubview:[backController view]];
    [UIView commitAnimations];

    //giving a heads up to the view that is about to come on screen
    [backController viewWillAppear:YES];

}



- (void)displayFront{

    [UIView beginAnimations:nil context:@"flipTransitionToFront"];
    [UIView setAnimationDuration:1.2];

    [UIView setAnimationDelegate:self];

    //I'm interested in knowing this has happened
    [UIView setAnimationDidStopSelector:@selector(flipAnimationDidEndWithID:finished:context:)];

    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
    //remove back view
    [[backController view] removeFromSuperview];
    //add the front view
    [self.view addSubview:[frontController view]];
    [UIView commitAnimations];

}  
0

view UIViewController - nib, , , .

It's hard to know exactly what happens without seeing more code, but you can get the results you need if you get access to the Pane.view parameters in viewDidLoad (you don't need to do anything with it, just get access to the property to force download).

0
source

Source: https://habr.com/ru/post/1709402/


All Articles