简体   繁体   English

带段控制器的UIPopOverController

[英]UIPopOverController with segment controller

How can i show the segmentcontroller in UIPopOverController like in this picture,PLs refer me any code? 我如何在UIPopOverController显示segmentcontroller, UIPopOverController所示,PL给我提供任何代码?

在此处输入图片说明

I have done this by the following code. 我是通过以下代码完成的。 I have added an IBAction for a button and added the following code, it worked perfectly for me. 我为按钮添加了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];
}

Here pop is UIPopoverController declared in the @ interface . 这里的pop是在@ interface声明的UIPopoverController

That's a standard menu that appears in a UITextField or UITextView . 这是出现在UITextFieldUITextView的标准菜单。 You don't have to write any code to get that menu in your own text fields or text views. 您无需编写任何代码即可在自己的文本字段或文本视图中获得该菜单。 Just tap in the text field or text view on the same location as the cursor or double-tap to select some text and the menu will appear automatically. 只需在与光标相同的位置点击文本字段或文本视图,或点按两次以选择一些文本,菜单就会自动出现。

Try with this WEPopover . 尝试使用此WEPopover You can use this and add your segment controller inside that. 您可以使用它并在其中添加段控制器。 You might have to customize the appearance of segmentcontroller for this kind of look and feel. 您可能必须针对这种外观自定义segmentcontroller的外观。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM