我如何UIPopOverController在这张图片中显示段控制器,请参考我的任何代码?

我已经通过以下代码做到了这一点。我添加了IBAction一个按钮并添加了以下代码,它对我来说非常有效。
- (IBAction)Test:(id)sender
{
UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"one",@"two",@"three", nil]];
UIViewController *tempView = [[UIViewController alloc] init];
tempView.view.frame = CGRectMake(0, 0, 180, 44);
[tempView.view addSubview:segment];
pop = [[UIPopoverController alloc] initWithContentViewController:tempView];
pop.popoverContentSize = CGSizeMake(180, 44);
[pop presentPopoverFromRect:CGRectMake(0, 0, 180, 44) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
}
这里pop是UIPopoverController在 @ 中声明的interface。
这是出现在UITextField或中的标准菜单UITextView。您无需编写任何代码即可在您自己的文本字段或文本视图中获取该菜单。只需在与光标相同的位置点击文本字段或文本视图或双击以选择一些文本,菜单将自动出现。
试试这个WEPopover。您可以使用它并在其中添加您的段控制器。您可能必须为这种外观定制段控制器的外观。