S.J
S.J

Reputation: 3071

Need assistance regarding UIActionSheet

I am trying to add UISegmentController to UIActionSheet here is my code

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];

Every thing is working fine but [actionSheet setFrame:CGRectMake(0, 0, 320, 500)]; is not working. How to increase the size of UIActionSheet to adjust with subview?

Upvotes: 0

Views: 62

Answers (1)

Saltymule
Saltymule

Reputation: 2937

The order is very important. You need to call showInView: on the UIActionsheet first, then adjust its size. Here is another question that addresses this:

adding view into action sheet

Upvotes: 1

Related Questions