iOS调用系统空间实现弹窗

来源:互联网 发布:yum requires nc 编辑:程序博客网 时间:2024/05/29 08:39

1.首先创建vc,并且重新系统方法

- (CGSize)preferredContentSize{

    

    if (self.presentingViewController && self.tableView !=nil ) {

        

        CGSize size =self.presentingViewController.view.bounds.size;

        size.width =200;

        

        CGSize size1 = [self.tableViewsizeThatFits:size];

        

        return size1;

    }else{

        

        return [superpreferredContentSize];

    }

    

    

}

2.在调用的页面直接初始化即可

 TestNewViewController *test = [[TestNewViewControlleralloc]init];

    test.modalPresentationStyle =UIModalPresentationPopover;

    test.popoverPresentationController.barButtonItem =self.navigationItem.rightBarButtonItem;

    test.popoverPresentationController.permittedArrowDirections =UIPopoverArrowDirectionUp;

    test.popoverPresentationController.delegate =self;

    [selfpresentViewController:testanimated:YEScompletion:nil];

3.在这里需要遵循协议,

UIPopoverPresentationControllerDelegate


并且实现方法

-(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller

{

    NSLog(@"%@",controller);

    return UIModalPresentationNone;

}





0 0
原创粉丝点击