【问题标题】:Covering a VIewController With another ViewController (NO animation or Transition)用另一个 ViewController 覆盖一个 VIewController(无动画或过渡)
【发布时间】:2016-09-20 13:23:32
【问题描述】:

这个问题之前可能问过,但我找不到任何相关问题,这就是为什么要发布一个新问题

所以我有 3 个选项卡,在 tab3 中我有用户配置文件选项卡 在 tab3 中我想显示 loginViewController(如果用户尚未登录),否则我想显示默认配置文件选项卡

我可以使用performSegue 传递一个segue,或者像这样展示一个视图控制器:

 let loginPageView =  self.storyboard?.instantiateViewController(withIdentifier: "LoginVC") as! SignupViewController
 self.present(loginPageView, animated: true, completion: nil)

但我不想要那个, 如果用户尚未登录没有任何动画或过渡

,我想在默认 VC 的位置显示不同的 VC

例如

producthunt 的 iOS 应用

如果用户没有登录

如果他确实登录了:

查看他们没有将其呈现为弹出式或模态的第一张图片。 似乎他们在同一个 VIewController 上执行此操作,但我不确定。有人可以在这里指导我吗?

【问题讨论】:

    标签: ios uiviewcontroller swift3


    【解决方案1】:

    用想要的 ViewController 替换当前的 Viewcontroller 就可以了

        let loginPageView =  self.storyboard?.instantiateViewController(withIdentifier: "LoginVC") as! SignupViewController
        var VCs =  self.navigationController?.viewControllers
    
        VCs?.removeLast() // here i removed the current VC
    
        VCs?.append(loginPageView) after that added the desired VC
    
        self.navigationController?.setViewControllers(VCs!, animated: false) // here i'm setting the viewcontrollers  with any animation.
    

    【讨论】:

      猜你喜欢
      • 2023-03-08
      • 2014-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-01
      • 2012-05-10
      相关资源
      最近更新 更多