programmatically present a new view controller in swift/programmatically give a class an Identifier
If you aren't using the storyboard you don't need an identifier. Just instantiate and present it.
let loadVC = SelectionScreen()
self.present(loadVC, animated: true, completion: nil)
How do I create a UIViewController programmatically?
UIViewController *controller = [[UIViewController alloc] init];
controller.view = whateverViewYouHave;
Do you have your own view controller that you coded? In that case you probably don't need to set the view property as it has been set in IB if that is what you used. When you have your controller you can push it onto the navigationController or view it modally etc.
How to create a UINavigationControll in UIViewController programmatically Swift
Maybe have a look at "Showing and Hiding View Controllers" where some navigation concepts are explained: https://developer.apple.com/documentation/uikit/view_controllers/showing_and_hiding_view_controllers
When using storyboards you should be able to use a segue to navigate from one view controller to another.
Instantiate UIViewController programmatically without nib
According to the docs:
If the view controller does not have an associated nib file, this method creates a plain UIView object instead.
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/#//apple_ref/occ/instp/UIViewController/view
If you do not provide a nib file when instantiating the view controller, UIViewController calls it's loadView()
method which creates a plain UIView object and assigns it to its view property.
The reason why you are seeing a transparent view is because the UIView object has no background color. To verify this, you can set the background color of the view controller's view property right before you push it on your navigation stack.
let viewController = TestViewController()
viewController.view.backgroundColor = .blueColor()
navigationController?.pushViewController(viewController, animated: true)
Related Topics
Didreceiveremotenotification Not Called in Background Mode
Native-Like Momentum-Scrolling on Body in iOS Webapp
Swift 3: Transfer Utility Enumeratetoassignblocks Method Signature
How to Check Bitfields (Scnetworkreachabilityflags in Particular) for Flags in Swift
iOS 14 Pickerview Cutting Off Text
How to Sort Core Data Array Based on Date Entered
Xcode Reference a Framework Instead of Link Binary with Libraries
Error Domain=Kclerrordomain Code=2 "The Operation Couldn't Be Completed. (Kclerrordomain Error 2.)"
Disabling Allowsbackgroundlocationupdates (Cllocationmanager) Doesn't Work After Is Was Enabled
How Come My Drawing Code Keeps Resulting in Fuzzy Shapes
Whats the Correct Way, Using "Init" or "Didmove"
How to Loop Through and Get All The Keys of The Nested Nodes in Firebase
Uitableview Is Jumping When I Insert New Rows
Uilabel Word Wrap Feature Leaving Space Even When Sufficient Space Available for The Word
Converting Nsdictionary to Xml