在我的应用程序中,我有一个UITableView和它的一个单元格UIButton.这个按钮有一个动作:
- (IBAction)showPopover:(UIButton *)sender
{
ChoseOptionsViewController *contentController = [[ChoseOptionsViewController alloc] init];
contentController.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *copvc = contentController.popoverPresentationController;
copvc.permittedArrowDirections = UIPopoverArrowDirectionAny;
copvc.sourceView = self.view;
copvc.sourceRect = sender.bounds;
contentController.preferredContentSize = CGSizeMake(200, 200);
[self presentViewController:contentController animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
问题是没有sender.bounds返回,所以弹出窗口显示在左上角self.view,而不是按钮的一侧.提前致谢.