iphone利用UIPopoverPresentationController实现popover

这个问题很简单,不废话,直接上代码

- (void)filterButtonAction:(UIButton *)sender
{
    SHSearchViewController *searchVC = nil;
    searchVC = [[SHSearchViewController alloc] initWithHotWordModel:self.hotwordModel];
    searchVC.preferredContentSize = CGSizeMake(300, 300);
    searchVC.modalPresentationStyle = UIModalPresentationPopover;
    searchVC.popoverPresentationController.sourceView = sender;
    searchVC.popoverPresentationController.sourceRect = sender.bounds;
    searchVC.popoverPresentationController.passthroughViews = @[self.searchBar];
    searchVC.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;
    searchVC.popoverPresentationController.delegate = self;
    [self presentViewController:searchVC animated:true completion:nil];
}

实现代理

-(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
{
    return UIModalPresentationNone;
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,823评论 25 709
  • 今天上午老师叫我们拿出昨天的回执单,其他的小朋友都拿出来了。我仔细地找了一遍书包却没找到,眼看着同学们把回执单收集...
    科幻LZY阅读 676评论 0 0
  • 昨天老解过寿,晚上小酌了几杯。可能是因为酒掺着喝的缘故,早上醒来只觉得浑身酸软,头有些昏沉。 于是约上老解,驱车十...
    想弹琴的砂子阅读 7,744评论 0 1
  • 烤地瓜在碳火上慵懒的抻着懒腰,可是他很怕,因为他淀粉含量那么高,吃了他大家长胖了怎么办?老爷爷偶尔翻动着他,他思考...
    我要养头驴阅读 1,313评论 0 1
  • 赖玉超:有故事的澡堂~ 2015年2月6号深圳赖玉超随笔 我是一个比较喜欢洗澡的人。就是像这么冷的天气,我还是会闷...
    laiyuchao阅读 1,852评论 0 0