【问题标题】:how to show view controller from UIPreviewAction in swift如何快速从 UIPreviewAction 显示视图控制器
【发布时间】:2023-04-11 12:42:02
【问题描述】:

我确实支持 3D Touch,我这样做是为了在使用强力拉动单元格时出现控制器,然后用户拿起它,他会看到动作,当用户点击它时会有一个按钮显示我想要的,控制器完全打开。如何显示此控制器?

 @available(iOS 9.0, *)
override func previewActionItems() -> [UIPreviewActionItem] {
    let showAction = UIPreviewAction(title: "Show", style: .Default) { [weak self] (action: UIPreviewAction, vc: UIViewController) -> Void in
        guard let weakSelf = self else {
            return;
        }

        if let _popAction = weakSelf.popAction {
            _popAction()
        }
        self?.showViewController(vc, sender: nil)
        print("show city controller")
    }

    return [showAction]
}

【问题讨论】:

    标签: ios swift swift2 ios9 3dtouch


    【解决方案1】:

    我改了代码

     @available(iOS 9.0, *)
    override func previewActionItems() -> [UIPreviewActionItem] {
        let showAction = UIPreviewAction(title: "Show", style: .Default) { [weak self] (action: UIPreviewAction, vc: UIViewController) -> Void in
            guard let weakSelf = self else {
                return;
            }
    
            if let _popAction = weakSelf.popAction {
                _popAction()
            }
            self?.showViewController(vc, sender: nil)
            print("show city controller")
        }
        let cityController = CityController() 
        cityController.showPreviewController()
        return [showAction]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-06
      • 2017-10-20
      • 2020-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多