需要有关UIActionSheet的帮助

时间:2013-05-08 18:30:12

标签: ios objective-c

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

1 个答案:

答案 0 :(得分:1)

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

adding view into action sheet