gpt4 book ai didi

ios - 需要有关 UIActionSheet 的帮助

转载 作者:行者123 更新时间:2023-11-29 03:56:19 29 4
gpt4 key购买 nike

我正在尝试将 UISegmentController 添加到 UIActionSheet 这是我的代码

UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Copy", @"New Key", nil];

NSArray *keyLengthOptions = [NSArray arrayWithObjects:@"Option 1", @"Option 2", nil];

UISegmentedControl *segmentController = [[UISegmentedControl alloc]initWithItems:keyLengthOptions];

segmentController.frame = CGRectMake(35, 0, 250, 38);

[segmentController addTarget:self action:@selector(segmentValueChanged:) forControlEvents:UIControlEventValueChanged];

[segmentController setSegmentedControlStyle:UISegmentedControlStyleBar];

[actionSheet addSubview:segmentController];

[actionSheet setFrame:CGRectMake(0, 0, 320, 500)];

[actionSheet showInView:self.navigationController.tabBarController.view];

一切工作正常,但 [actionSheet setFrame:CGRectMake(0, 0, 320, 500)]; 不起作用。如何增加UIActionSheet的大小以随 subview 进行调整?

最佳答案

顺序非常重要。您需要先在UIActionsheet上调用showInView:,然后调整其大小。这是解决此问题的另一个问题:

adding view into action sheet

关于ios - 需要有关 UIActionSheet 的帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16447716/

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