小编pil*_*eem的帖子

UIPopoverPresentationController来自UITableViewCell中的一个按钮

在我的应用程序中,我有一个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,而不是按钮的一侧.提前致谢.

objective-c uitableview ios

3
推荐指数
1
解决办法
2408
查看次数

标签 统计

ios ×1

objective-c ×1

uitableview ×1