mirror of
https://github.com/wnagrodzki/ViewControllerContainment.git
synced 2025-04-05 20:01:57 +02:00
VCCAutomaticCallbacksViewController, first view controllers enters with animation after view appears. Add comments.
This commit is contained in:
parent
b4e7679ed1
commit
728a5267fd
1 changed files with 22 additions and 10 deletions
|
@ -72,14 +72,6 @@
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewDidLoad
|
|
||||||
{
|
|
||||||
[super viewDidLoad];
|
|
||||||
|
|
||||||
if (self.viewControllers.count)
|
|
||||||
[self displayViewController:self.viewControllers[0]];
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - Overriden (Appearanca Callbacks)
|
#pragma mark - Overriden (Appearanca Callbacks)
|
||||||
|
|
||||||
- (void)viewWillAppear:(BOOL)animated
|
- (void)viewWillAppear:(BOOL)animated
|
||||||
|
@ -92,6 +84,10 @@
|
||||||
{
|
{
|
||||||
NGLogMessage();
|
NGLogMessage();
|
||||||
[super viewDidAppear:animated];
|
[super viewDidAppear:animated];
|
||||||
|
|
||||||
|
if (self.viewControllers.count)
|
||||||
|
[self displayViewController:self.viewControllers[0]];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewWillDisappear:(BOOL)animated
|
- (void)viewWillDisappear:(BOOL)animated
|
||||||
|
@ -111,29 +107,38 @@
|
||||||
|
|
||||||
- (void)cycleFromViewController:(UIViewController *)fromViewController toViewController:(UIViewController *)toViewController forward:(BOOL)forward
|
- (void)cycleFromViewController:(UIViewController *)fromViewController toViewController:(UIViewController *)toViewController forward:(BOOL)forward
|
||||||
{
|
{
|
||||||
|
// powiadomienie fromViewController że zostanie usunięty z hierarchii kontrolerów
|
||||||
[fromViewController willMoveToParentViewController:nil];
|
[fromViewController willMoveToParentViewController:nil];
|
||||||
|
// dodanie toViewController do hierarchi kontrolerów
|
||||||
|
// metoda [toViewController willMoveToParentViewController:self] jest wywołana automatycznie przez -addChildViewController:
|
||||||
[self addChildViewController:toViewController];
|
[self addChildViewController:toViewController];
|
||||||
|
|
||||||
|
// ustawenie ramki widoku nowego kontrolera
|
||||||
CGRect frame = self.containerView.bounds;
|
CGRect frame = self.containerView.bounds;
|
||||||
frame.origin.x = forward ? frame.size.width : -frame.size.width;
|
frame.origin.x = forward ? frame.size.width : -frame.size.width;
|
||||||
toViewController.view.frame = frame;
|
toViewController.view.frame = frame;
|
||||||
|
|
||||||
|
// ta metoda automatycznie usunie widok starego kontrolera z hierarchi oraz doda widok nowego
|
||||||
[self transitionFromViewController:fromViewController
|
[self transitionFromViewController:fromViewController
|
||||||
toViewController:toViewController
|
toViewController:toViewController
|
||||||
duration:0.3
|
duration:0.3
|
||||||
options:UIViewAnimationOptionCurveEaseInOut
|
options:UIViewAnimationOptionCurveEaseInOut
|
||||||
animations:^{
|
animations:^{
|
||||||
|
// animacja wyjścia widoku starego kontrolera
|
||||||
CGRect frame = self.containerView.bounds;
|
CGRect frame = self.containerView.bounds;
|
||||||
frame.origin.x = forward ? -frame.size.width : frame.size.width;
|
frame.origin.x = forward ? -frame.size.width : frame.size.width;
|
||||||
fromViewController.view.frame = frame;
|
fromViewController.view.frame = frame;
|
||||||
|
|
||||||
|
// animacja wejścia widoku nowego kontrolera
|
||||||
toViewController.view.frame = self.containerView.bounds;
|
toViewController.view.frame = self.containerView.bounds;
|
||||||
}
|
}
|
||||||
completion:^(BOOL finished) {
|
completion:^(BOOL finished) {
|
||||||
|
// powiadominie toViewController że został dodany jako child view controller
|
||||||
[toViewController didMoveToParentViewController:self];
|
[toViewController didMoveToParentViewController:self];
|
||||||
|
// usunięcie starego kontrolera z hierarchi kontrolerów
|
||||||
[fromViewController removeFromParentViewController];
|
[fromViewController removeFromParentViewController];
|
||||||
|
// metoda [fromViewController didMoveToParentViewController:nil] jest wywołana automatycznie przez -removeFromParentViewController
|
||||||
}];
|
}];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)displayViewController:(UIViewController *)controller
|
- (void)displayViewController:(UIViewController *)controller
|
||||||
|
@ -146,8 +151,15 @@
|
||||||
|
|
||||||
[self addChildViewController:controller];
|
[self addChildViewController:controller];
|
||||||
controller.view.frame = self.containerView.bounds;
|
controller.view.frame = self.containerView.bounds;
|
||||||
|
controller.view.alpha = 0;
|
||||||
[self.containerView addSubview:controller.view];
|
[self.containerView addSubview:controller.view];
|
||||||
[controller didMoveToParentViewController:self];
|
|
||||||
|
[UIView animateWithDuration:2
|
||||||
|
animations:^{
|
||||||
|
controller.view.alpha = 1;
|
||||||
|
} completion:^(BOOL finished) {
|
||||||
|
[controller didMoveToParentViewController:self];
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - OtherPerfectClassDelegate
|
#pragma mark - OtherPerfectClassDelegate
|
||||||
|
|
Loading…
Add table
Reference in a new issue