0

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;
}
}
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Sumit Kumar
  • 402
  • 1
  • 6
  • 26
  • As a test, try changing the frame of the button so it appears closer to the top. – rmaddy Mar 10 '14 at 14:25
  • i have tried changing the frame but still it is not appearing – Sumit Kumar Mar 10 '14 at 14:28
  • 1
    Try creating the button properly - `UIButton *addData = [UIButton buttonWithType:UIButtonTypeCustom];`. Then set its frame and title. – rmaddy Mar 10 '14 at 14:30
  • As commented by @maddy.. http://stackoverflow.com/questions/1378765/how-do-i-create-a-basic-uibutton-programmatically – joe Mar 10 '14 at 14:35

0 Answers0