2013-05-08 59 views
0

我想補充UISegmentController這裏UIActionSheet援助是我的代碼需要更多關於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

訂單非常重要。您需要先調用showInView:在UIActionsheet上,然後調整其大小。這是另外一個問題,解決這樣的:

adding view into action sheet

+0

非常感謝,它的工作。您能否告訴我爲什麼呼叫順序在這種情況下很重要? – 2013-05-08 19:01:25

+1

因爲showInview:設置操作表上的邊界和中心。如果您在調用showInView之前設置了框架,它將被覆蓋。 – Saltymule 2013-05-14 13:15:40

相關問題