美文网首页
iphone利用UIPopoverPresentationCon

iphone利用UIPopoverPresentationCon

作者: 多来猫 | 来源:发表于2018-08-03 17:55 被阅读0次

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

- (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;
}

相关文章

网友评论

      本文标题:iphone利用UIPopoverPresentationCon

      本文链接:https://www.haomeiwen.com/subject/dllkvftx.html