I am adding child view controller to main view, child view controller contains two buttons that have their action methods defined in child view controller class. On the action of those buttons need to dismiss the child view controller. Is there any way to do so or better way to do.
Please guide. Thanks in advance.
Note: ChildViewController contains custom popup view, not using UIAlertController.
Update: Code in MainViewController
-(void)showAlertView
{
customAlertView = [[CustomAlertController alloc] init];
[self displayContentController:customAlertView :msg :cancel :delete];
}
- (void) displayContentController: (UIViewController*) content: (NSString *) alertMsg: (NSString *) btnOneTitle: (NSString *) btnTwoTitle
{
[self addChildViewController:content]; // 1
content.view.bounds = self.view.bounds; //2
content.strAlertMsg = alertMsg;
[content.view setFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, self.view.frame.size.height)];
[self.view addSubview:content.view];
[content didMoveToParentViewController:self]; // 3
}
// ChildViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.lblMsg.text = strAlertMsg;
[self.btnCancel setTitle:strBtnTitle1 forState:UIControlStateNormal];
[self.btnDelete setTitle:strBtnTitle2 forState:UIControlStateNormal];
}
Question: How to pass data from parent to child view controller