UIButton没有出现在PopoverView中

时间:2014-03-10 14:18:26

标签: ios uibutton uipopovercontroller

我已经为popovermenu编写了这段代码,我正在添加三个UITextField和一个UIButton,问题是所有的文本字段都显示正确,但按钮没有出现。 这是我的功能代码:

- (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;
}
}

0 个答案:

没有答案