简体   繁体   中英

UIPopOverController with segment controller

How can i show the segmentcontroller in UIPopOverController like in this picture,PLs refer me any code?

在此处输入图片说明

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)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 .

That's a standard menu that appears in a UITextField or 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.

Try with this 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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