代码之家  ›  专栏  ›  技术社区  ›  Uday Babariya

为iPhone将Popover显示为全屏

  •  1
  • Uday Babariya  · 技术社区  · 6 年前
    @ibaction func temp(u sender:uibutton){
    
    vc.modalPresentationStyle=.popoover
    
    让Popover=vc.PopOverPresentationController!
    popover.sourceRect=self.btnemp.bounds
    自我呈现(vc,动画:真,完成:零)
    
    
    返回。无
    
    

    但它覆盖了整个屏幕。

    uped:I want to achieve like this:

    这里是我的代码:

      @IBAction func temp(_ sender: UIButton) {
        let vc = UIStoryboard(name: "StayView", bundle: nil).instantiateViewController(withIdentifier: "StayViewPopOverViewController") as! StayViewPopOverViewController
    
        vc.modalPresentationStyle = .popover
        vc.preferredContentSize = CGSize(width: 180, height: 75)
    
        let popover = vc.popoverPresentationController!
        popover.sourceView = self.btnTemp
        popover.sourceRect = self.btnTemp.bounds
        popover.delegate = self
        self.present(vc, animated: true, completion: nil)
    }
    

     func adaptivePresentationStyleForPresentationController(controller: UIPresentationController!) -> UIModalPresentationStyle {
        return .none
    }
    


    我试图在委托方法上放置断点,但解释器没有停止。

    升级:

    2 回复  |  直到 6 年前
        1
  •  0
  •   Pravin Tate    6 年前

    更新以下行

     vc.modalPresentationStyle = .popover
     vc.preferredContentSize = CGSize(width: 180, height: 75)
    

    vc.modalPresentationStyle = .overFullScreen
    vc.preferredContentSize = view.frame.size
    
        2
  •  0
  •   Uday Babariya    6 年前

    最后我得到了答案。

     func adaptivePresentationStyle(
        for controller: UIPresentationController,
        traitCollection: UITraitCollection)
        -> UIModalPresentationStyle {
            return .none
    }