0

我有以下代码来打开一个 320px x 320px UIPopoverController,但由于某种原因,弹出框比它应该高得多 - 大约是我指定的高度(320px)的两倍。

出了什么问题?

    colorPicker = [[RSColorPickerView alloc] initWithFrame:CGRectMake(20.0, 20.0, 320.0, 320.0)];
    [colorPicker setDelegate:self];
    [colorPicker setBrightness:1.0];
    [colorPicker setCropToCircle:YES];
    [colorPicker setBrightness:1.0];
    [colorPicker setBackgroundColor:[UIColor clearColor]];

    UIColor * aColor = [UIColor colorWithRed:0.803 green:0.4 blue:0.144 alpha:1];
    [colorPicker setSelectionColor:aColor];

    UIView *newview = [[UIView alloc] initWithFrame:CGRectMake(20.0, 20.0, 320.0, 320.0)];
    [newview addSubview:colorPicker];

    UIViewController *newviewcontroller = [[UIViewController alloc] init];
    [newviewcontroller setView:newview];

    UIPopoverController *newpopover =
    [[UIPopoverController alloc] initWithContentViewController:newviewcontroller];

    newpopover.delegate = self;
    [self.colourController setPopoverContentSize:CGSizeMake(320, 320)];
    self.colourController = newpopover;

    [self.colourController presentPopoverFromRect:CGRectMake(149, 540, 1, 1) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
4

1 回答 1

2

您需要popoverContentSize在弹出窗口中显示的视图控制器上设置 。您将其设置在错误的视图控制器上。

newpopover.delegate = self;
self.colourController = newpopover;
[self.colourController setPopoverContentSize:CGSizeMake(320, 320)];

你在做这最后两行的时候是乱序的。

于 2012-11-08T17:32:58.863 回答