Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 需要关于UIActionSheet的帮助吗_Ios_Objective C - Fatal编程技术网

Ios 需要关于UIActionSheet的帮助吗

Ios 需要关于UIActionSheet的帮助吗,ios,objective-c,Ios,Objective C,我正在尝试将UISegmentController添加到UIActionSheet中这是我的代码 UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Copy", @"New Key", nil]; NSArray *keyLengt

我正在尝试将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,0320500)]不工作。如何增加UIActionSheet的大小以使用子视图进行调整?

顺序非常重要。您需要首先在UIActionsheet上调用showInView:,然后调整其大小。这里还有一个问题可以解决这个问题:


非常感谢,它成功了。你能告诉我为什么呼叫顺序在这个场景中很重要吗?因为showInview:在操作表上设置边界和中心。如果在调用showInView:之前设置了帧,它将被覆盖。