UIPopoverPresentationController 用法


MyViewController *viewController = [[MyViewController alloc] init];

viewController.modalPresentationStyle = UIModalPresentationPopover;

emptyViewController.preferredContentSize = CGSizeMake(300, 200);

UIPopoverPresentationController *pop = emptyViewController.popoverPresentationController;

pop.sourceRect = CGRectMake(10, 10, 20, 20);

pop.sourceView = self.view;

pop.delegate = self;

[self.navigationController presentViewController:emptyViewController animated:YES completion:nil];

如果想在 iPhone 上也显示为非全屏的弹出框,需要实现 UIPopoverPresentationControllerDelegate 协议的方法,返回 UIModalPresentationNone 即可:

- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller {

   return UIModalPresentationNone;

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,262评论 4 61
  • 写来写去文字剧 情感情绪装进去 不休不息憨带劲 晚睡早起有乐趣 少时读书不努力 青年时期没记忆 玩来玩去过中年 老...
    胡杨公主阅读 201评论 3 9
  • ◆◇ 学会管理好自己的时间 ◇◆ 我和女儿早就商量好了,如果本周女儿做作业效率高的话,周日上午学完小提琴之后就可以...
    勿忘初心丨阅读 200评论 0 0
  • 【反应第二】(2.2) 人言者,动也;已默者,静也。因其言,听其辞。言有不合者,反而求之,其应必出。言有象,事有比...
    温翀阅读 365评论 0 1
  • 01 前几日,小十月肠胃不好,上吐下泻,他的小棉被上也是一片狼藉。翌日,把他的小棉被拆开,将被套清洗干净,连同棉絮...
    Miss苏朵儿阅读 1,238评论 4 5