gpt4 book ai didi

iphone - 带有段 Controller 的 UIPopOverController

转载 作者:行者123 更新时间:2023-11-29 13:25:30 26 4
gpt4 key购买 nike

如何在 UIPopOverController 中显示 segmentcontroller,就像这张照片一样,PLs 给我任何代码?

enter image description here

最佳答案

我已通过以下代码完成此操作。我为按钮添加了一个 IBAction 并添加了以下代码,它对我来说非常有效。

- (IBAction)Test:(id)sender
{
UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"one",@"two",@"three", nil]];
UIViewController *tempView = [[UIViewController alloc] init];
tempView.view.frame = CGRectMake(0, 0, 180, 44);
[tempView.view addSubview:segment];
pop = [[UIPopoverController alloc] initWithContentViewController:tempView];
pop.popoverContentSize = CGSizeMake(180, 44);
[pop presentPopoverFromRect:CGRectMake(0, 0, 180, 44) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
}

这里的pop是在@interface中声明的UIPopoverController

关于iphone - 带有段 Controller 的 UIPopOverController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13244229/

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