I am trying to add popup programmatically to view controller. i am trying this code but not working.
[self.view addSubview:viewSelectZoneToAddVisit];
I am trying to add popup programmatically to view controller. i am trying this code but not working.
[self.view addSubview:viewSelectZoneToAddVisit];
- (void)viewDidLoad
{
[super viewDidLoad];
viewSelectZoneToAddVisit *viewSelectZoneToAddVisit = [[NSBundle mainBundle] loadNibNamed:@"viewSelectZoneToAddVisit" owner:self options:nil][0]; // @"viewSelectZoneToAddVisit" is your XIB Name in Main Bundle
[viewSelectZoneToAddVisit setFrame:(CGRect){0,0,300,400}]; // setting frame for your view
[viewSelectZoneToAddVisit setCenter:self.view.center]; // set your view's center as self.view's center (Optional)
[viewSelectZoneToAddVisit setBackgroundColor:[UIColor redColor]]; // setting bg color
// Design your sub views & Add them to viewSelectZoneToAddVisit
// Finally add it as a subView of self.view
[self.view addSubview:viewSelectZoneToAddVisit]; // adding it as a sub view for self.view
}
For add child view controller
//add childview
[self addChildViewController:yourViewControllerObject];
[self.view addSubview:yourViewControllerObject.view];
[yourViewControllerObject didMoveToParentViewController:self];
Remove from child view controller (add below code in your popup view for dismiss)
//remove from chiuld view controller
[self removeFromParentViewController];
[self didMoveToParentViewController:nil];
[self.view removeFromSuperview];