I create a modal UIView with .xib, and when I click to button, I want display this UIView. But I have an error in the presentViewController : Sending 'void' to parameter of incompatible type 'UIViewController'. Thanks for your answers.
- (void)modal {
modalViewController *mvc = [[modalViewController alloc] initWithNibName:@"modalViewController" bundle:nil];
UIView * modal = [[UIView alloc] initWithFrame:CGRectMake(self.view.center.x/2, self.view.center.y/2, 240, 320)];
modal.backgroundColor = [UIColor whiteColor];
[modal addSubview:mvc.view];
[self.view addSubview:modal];
}
- (IBAction)showBTN:(id)sender {
[self presentViewController:[self modal] animated:YES completion:nil];
}
The
presentViewController:animated:completion:first parameter is an instance ofUIViewControllernotvoid.What you are trying to do makes not sense, since you are already adding the view from the
modalViewControllerto the currentUIViewControllersview. So there is no need to callpresentViewController:animated:completion:.This will add the view to your current view hierarchy:
Also a small remark, classes should start with a capital letter, so your
modalViewControllerclass should actually be namedModalViewController.