Reputation: 338
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
Upvotes: 0
Views: 2108
Reputation: 51
@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];
}
Upvotes: 1
Reputation: 3438
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.
Upvotes: 1
Reputation: 402
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
Upvotes: 1