I have written this code for popovermenu and i am adding three UITextFields and one UIButton, the problem is that all the textfields are appearing correctly but the button is not appearing. This is the code of my function:
- (IBAction)addProfile:(UIBarButtonItem *)sender {
UIViewController *popmenu = [[UIViewController alloc] init];
popmenu.contentSizeForViewInPopover = CGSizeMake(400, 400);
if (_colorPickerPopover == nil) {
_colorPickerPopover = [[UIPopoverController alloc] initWithContentViewController:popmenu];
UITextField *name = [[UITextField alloc] initWithFrame:CGRectMake(60, 28, 300, 28)];
name.placeholder = @"Company Name";
[_colorPickerPopover.contentViewController.view addSubview:name];
UITextField *angle = [[UITextField alloc] initWithFrame:CGRectMake(60, 108, 300, 28)];
angle.placeholder = @"View Angle in deg";
[_colorPickerPopover.contentViewController.view addSubview:angle];
UITextField *maxdist = [[UITextField alloc] initWithFrame:CGRectMake(60, 188, 300, 28)];
maxdist.placeholder = @"Maximum Distance in mtrs";
[_colorPickerPopover.contentViewController.view addSubview:maxdist];
UIButton *addData = [[UIButton alloc] initWithFrame:CGRectMake(80, 280, 180, 30)];
int state = UIControlStateNormal | UIControlStateHighlighted | UIControlStateDisabled | UIControlStateSelected;
[addData setTitle:@"Add Profile" forState:state];
[_colorPickerPopover.contentViewController.view addSubview:addData];
[_colorPickerPopover presentPopoverFromBarButtonItem:(UIBarButtonItem *) sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
} else {
[_colorPickerPopover dismissPopoverAnimated:YES];
_colorPickerPopover = nil;
}
}