I followed this link to implement a fully functional unit
@interface : ParentViewController () @property (nonatomic, strong) ChildViewController *childViewController; @end
In the controller table view of the parent view, the delegate method (didSelectRowAtIndexPath) I add a container view as follows
- (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]; }
Interface and implementation of ChildViewController
@interface ChildViewController : UIViewController @property (nonatomic, copy) void (^completionCallBack) (); @end - (IBAction)cancelPressed:(id)sender { self.completionCallBack (); }
when I try to call completeCallBack inside the button action, I get a bad access error. 
I'm not sure what mistake I am making here, any help is much appreciated.
objective-c ios9 uicontainerview objective-c-blocks
Peer mohamed thabib
source share