Dismiss and Present View Controller in Swift

前端 未结 5 673
生来不讨喜
生来不讨喜 2020-12-09 11:52

Hi I\'m trying to present a viewcontroller and dismiss my current modal view but this code is not working

self.dismissViewControllerAnimated(true, completion         


        
5条回答
  •  隐瞒了意图╮
    2020-12-09 12:10

    I think there is a mistake in your code where 'self' should be the presenting view controller to present 'vc', not 'vc' its self

    Your code

    self.dismissViewControllerAnimated(true, completion: {
                    let vc = self.storyboard?.instantiateViewControllerWithIdentifier("OrderViewController")
                    vc!.presentViewController(vc!, animated: true, completion: nil)
                })
    

    Try this

    self.dismissViewControllerAnimated(true, completion: {
                    let vc = self.storyboard?.instantiateViewControllerWithIdentifier("OrderViewController")
                    self.presentViewController(vc!, animated: true, completion: nil)
                })
    

    hope this is helpful

提交回复
热议问题