为什么UIPopoverController如此之高?

时间:2012-11-08 17:29:01

标签: iphone objective-c ios xcode uipopovercontroller

我有以下代码打开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];

1 个答案:

答案 0 :(得分:2)

您需要在弹出框中显示的视图控制器上设置popoverContentSize。您正在错误的视图控制器上进行设置。

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

你最后两行无序。