ich diesen link gefolgt haben die compleltionblockGriff ContainerViewController Handeln in parent
@interface : ParentViewController()
@property (nonatomic, strong) ChildViewController *childViewController;
@end
In Eltern-View-Controller des Tabellenansicht Delegate-Methode (DidSelectRowAtIndexPath) Ich addiere Container Ansicht zu implementieren, wie
- (void) addChildView {
ChildViewController * childViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ChildViewController"];
childViewController.view.frame = (CGRect) {0, 0, self.view.frame.size};
[self addChildViewController:childViewController];
__block ParentViewController *parentViewController = self;
[parentViewController.childViewController setCompletionCallBack:^{
self.childViewController.view.backgroundColor = [UIColor clearColor];
[UIView animateWithDuration:0.5f delay:0.0f options:UIViewAnimationOptionCurveEaseIn animations:^{
self.childViewController.view.frame = (CGRect) {0, 1000, self.view.frame.size};
} completion:^(BOOL finished) {
[self.childViewController.view removeFromSuperview];
self.childViewController = nil;
}];
}];
[self.view addSubview: childViewController.view];
[childViewController didMoveToParentViewController:self];
[UIView animateWithDuration:0.5f animations:^{
childViewController.view.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.15f];
[self.view layoutIfNeeded];
} completion:nil];
}
ChildViewController der folgt Schnittstelle und Implementierung
@interface ChildViewController : UIViewController
@property (nonatomic, copy) void (^completionCallBack)();
@end
- (IBAction)cancelPressed:(id)sender {
self.completionCallBack();
}
wenn ich versuche, die completionCallBack innerhalb der Schaltfläche Aktion Ich bekomme einen schlechten Zugriffsfehler.
Ich bin mir nicht sicher, welchen Fehler ich hier mache, jede Hilfe sehr geschätzt.