[英]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
. 这是出现在
UITextField
或UITextView
的标准菜单。 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.
只需在与光标相同的位置点击文本字段或文本视图,或点按两次以选择一些文本,菜单就会自动出现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.