1.
控制器可以自适应大小。
self
.
preferredContentSize
=
CGSizeMake
(
200
,
400
);
2.弹出控制器框
-(void)clickSortButton{
//继承UIViewController
self.sortViewController.modalPresentationStyle = UIModalPresentationPopover;
//相对sortbutton具体的位置
//继承UIViewController
self.sortViewController.modalPresentationStyle = UIModalPresentationPopover;
//相对sortbutton具体的位置
self.sortViewController.popoverPresentationController.sourceView =self.headerView.sortButton;
//指定相对排序button的位置
self.sortViewController.popoverPresentationController.sourceRect = CGRectMake(self.headerView.sortButton.frame.size.width/2, self.headerView.sortButton.frame.size.height, 0, 0);
self.sortViewController.popoverPresentationController.sourceRect = self.headerView.sortButton.bounds;
self.sortViewController.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionAny;
self.sortViewController.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionAny;
self.sortViewController.popoverPresentationController.delegate = self;
[self presentViewController:self.sortViewController animated:YES completion:nil];
}
#pragma mark -
UIPopoverPresentationControllerDelegate
//不然不显示弹出控制器
-(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller{
return UIModalPresentationNone;
}