Uipopovercontroller was abandoned after iOS9, and,
IOS8 new control Uipopoverpresentationcontroller can be used on iphone and ipad, using basic same Uipopovercontroller
- -(void) Ipadandiphonepopover {
Menuviewcontroller *MENUVC = [[Menuviewcontroller alloc] init];
Menuvc.modalpresentationstyle = Uimodalpresentationpopover;
MenuVC.popoverPresentationController.sourceView = Self.view;
MenuVC.popoverPresentationController.sourceRect = Self.testButton.frame;
MenuVC.popoverPresentationController.permittedArrowDirections = Uipopoverarrowdirectionup;
[Self PRESENTVIEWCONTROLLER:MENUVC animated:yes completion:nil];
}
Code2:*-(Ibaction) PopOver: (ID) Sender {Addressviewcontroller*CONTENTVC =[[Addressviewcontroller alloc] init]; Contentvc.modalpresentationstyle=Uimodalpresentationpopover; ContentVC.popoverPresentationController.sourceView=Self.view; ContentVC.popoverPresentationController.sourceRect= CGRectMake ( -, -, -, -); ContentVC.popoverPresentationController.permittedArrowDirections=Uipopoverarrowdirectionup; [Self PRESENTVIEWCONTROLLER:CONTENTVC animated:yes completion:nil];}*ADDRESSVIEWCONTROLLER.M*#import "AddressViewController.h"@interfaceAddressviewcontroller () <uitableviewdelegate, uitableviewdatasource>@property (Weak, nonatomic) Iboutlet UITableView*mastertableview;//Province TableView@property (Weak, nonatomic) Iboutlet UITableView *detailtableview;//area TableView@property (nonatomic, strong) Nsarray*masterdatasource;//Province Data Source@property (nonatomic, strong) Nsarray *detaildatasource;//Regional data Sources@property (nonatomic, assign)intMasterindex;//Selected Provinces@end@implementationAddressviewcontroller- (void) viewdidload {[Super viewdidload]; _masterindex=0; Self.preferredcontentsize= Cgsizemake ( Max, -);}-(Nsarray *) Masterdatasource {if(_masterdatasource = =Nil) {_masterdatasource= @[@"Henan",@"Hebei",@"Jiangsu",@"Zhejiang",@"Guangdong"]; } return_masterdatasource;}-(Nsarray *) Detaildatasource {if(_detaildatasource = =Nil) {_detaildatasource= @[@[@"Zhengzhou",@"Luoyang",@"Zhoukou",@"Kaifeng"], @[@"Shijiazhuang",@"Shijiazhuang 2"], @[@"Nanjing",@"Suzhou",@"Huaian",@"Huaibei",@"Jurong"], @[@"Hangzhou",@"Wenzhou",@"Taizhou",@"Ningbo",@"Ruian",@"Cangnan"], @[@"Guangzhou",@"Shenzhen"] ]; } return_detaildatasource;}-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) Section {if(TableView = =Self.mastertableview) {returnSelf.masterDataSource.count; } if(TableView = =Self.detailtableview) {return[Self.detaildatasource[_masterindex] count]; } return 0;}-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath {if(TableView = =self.mastertableview) {UITableViewCell*cell = [TableView dequeuereusablecellwithidentifier:@"Master"]; if(Cell = =Nil) {Cell= [[UITableViewCell alloc] Initwithstyle:uitableviewcellstyledefault reuseidentifier:@"Master"]; } Cell.textLabel.text=Self.masterdatasource[indexpath.row]; returncell; } UITableViewCell*cell = [TableView dequeuereusablecellwithidentifier:@"Detail"]; if(Cell = =Nil) {Cell= [[UITableViewCell alloc] Initwithstyle:uitableviewcellstyledefault reuseidentifier:@"Detail"]; } Cell.textLabel.text=Self.detaildatasource[_masterindex][indexpath.row]; returncell;}- (void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) Indexpath {if(TableView = =_mastertableview) {_masterindex= (int) Indexpath.row; Self.preferredcontentsize= Cgsizemake ( -, -); [_detailtableview Reloaddata]; } if(TableView = =_detailtableview) {Self.preferredcontentsize= Cgsizemake ( Max, -); [_detailtableview Reloaddata]; }}@end
Note: If you want to remove the arrow permittedarrowdirections = 0; and to set theSourceview, sourcerect It won't take effect until then.
IPad control Uipopoverpresentationcontroller available with iphone