0

我正在尝试将 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 的大小以调整子视图?

4

1 回答 1

1

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

将视图添加到操作表中

于 2013-05-08T18:53:55.053 回答