1

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

在此处输入图像描述

4

3 回答 3

1

我已经通过以下代码做到了这一点。我添加了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];
}

这里popUIPopoverController在 @ 中声明的interface

于 2012-11-06T04:29:26.533 回答
0

这是出现在UITextField或中的标准菜单UITextView。您无需编写任何代码即可在您自己的文本字段或文本视图中获取该菜单。只需在与光标相同的位置点击文本字段或文本视图或双击以选择一些文本,菜单将自动出现。

于 2012-11-06T04:16:17.647 回答
0

试试这个WEPopover。您可以使用它并在其中添加您的段控制器。您可能必须为这种外观定制段控制器的外观。

于 2012-11-06T05:37:57.643 回答