0

I have been searching for almost 2 hours on how to implement UIPopoverController in swift language, at the end, i found out that this api are exclusive for iPad devices only.

How will i be able to make a drop down list on iPhone devices?

please someone help me, at lease with the name of the api so that i know what to search for

Aryam Saleh
  • 338
  • 2
  • 12
  • you can, but the HIG presents / offers different solutions for iPhone as the screen is not big enough for a popup; you may find the `UIPickerView` interesting. – holex May 20 '15 at 11:47

3 Answers3

1

You can you third party libraries for that:

or if you don't need iOS 7 support you can use iOS 8 new API which answered in this question

Community
  • 1
  • 1
Dima Cheverda
  • 402
  • 1
  • 4
  • 10
1

i depends on your needs. You can show UIPickerView, present an action sheet or segue to another VC and then go back - these are standard ways.

Kubba
  • 3,390
  • 19
  • 34
1
@property(nonatomic,retain) UIPopoverPresentationController *popoverPresentationController;

- (IBAction)showPopover:(id)sender {
    UIViewController *popoverViewController = [[UIViewController alloc] initWithNibName:@"NameViewController" bundle:nil];
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:popoverViewController];
    popoverViewController.preferredContentSize = CGSizeMake(280, 200);
    navigationController.modalPresentationStyle = UIModalPresentationPopover;
    _popoverPresentationController = navigationController.popoverPresentationController;
    _popoverPresentationController.delegate = self;
    _popoverPresentationController.sourceView = self.view;
    _popoverPresentationController.sourceRect = [sender frame];
    navigationController.modalPresentationStyle = UIModalPresentationPopover;
    navigationController.navigationBarHidden = YES;
    [_viewController presentViewController:navigationController animated:YES completion:nil];

}