Home > other >  Showing a View after ViewController
Showing a View after ViewController

Time:02-16

In UIKit I have a single View created in Xcode. View How can I present or show that from View a UIViewController class after a button is hit? Because present(vc, animated: true) only works for ViewControllers...

CodePudding user response:

You must first connect it to the view property of some controller, and then present that controller

For this:

  1. Open your View (.xib) file
  2. Select "File's Owner" in left section pane
  3. Select "Show the Attribute inspector" in right section pane
  4. Enter the class name of the ViewController that you want to attach this view to (for example: MyViewController)
  5. Select "Show the Connections Inspector" in right section pane
  6. Connect view outlet to the your view

After that you can initialize your class and present in somewhere after tap/click

  • Related