gpt4 book ai didi

iphone - 为什么 UIPopoverController 这么高大上?

转载 作者:行者123 更新时间:2023-11-28 22:45:37 24 4
gpt4 key购买 nike

我有以下代码可以打开一个 320px x 320px 的 UIPopoverController,但由于某种原因,popover 比它应该的高度高得多 - 大约是我指定高度 (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];

最佳答案

您需要在弹出窗口中显示的 View Controller 上设置 popoverContentSize。您将其设置在错误的 View Controller 上。

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

最后两行的顺序不对。

关于iphone - 为什么 UIPopoverController 这么高大上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13294429/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com