viewcontroller
Cannot call value of non-function type ‘String’
The error is telling you that you are trying to call a String instead of a method (struct constructor in your case). You’ve probably declared a String variable named ILT (uppercase) somewhere else and that’s why it fails. Your posted code works fine so the error must be somewhere else in your code.
Only ONE VIEW landscape mode
Swift AppDelegate.swift internal var shouldRotate = false func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { return shouldRotate ? .allButUpsideDown : .portrait } Your landscape view controller let appDelegate = UIApplication.shared.delegate as! AppDelegate appDelegate.shouldRotate = true // or false to disable rotation Objective-C AppDelegate.h @property (assign, nonatomic) BOOL shouldRotate; AppDelegate.m – (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow … Read more
Swift: Reload a View Controller
Whatever code you are writing in viewDidLoad, Add that in viewWillappear(). This will solve your problem.
Dismiss more than one view controller simultaneously
@Ken Toh’s comment was what worked for me in this situation — call dismiss from the view controller that you want to show after everything else is dismissed. If you have a “stack” of 3 presented view controllers A, B and C, where C is on top, then calling A.dismiss(animated: true, completion: nil) will dismiss … Read more
Xcode – How to connect XIB to ViewController Class
Click to select the xib. Now, select the file’s owner. In the attribute panel on the right side, choose the third tab, “Identity Inspector”. There is a header named Custom Class. Give your view controller’s name there. After this, you can connect the elements with the file’s owner.
Loading ViewController from xib file
Swift 3 let myViewController = MyViewController(nibName: “MyViewController”, bundle: nil) self.present(myViewController, animated: true, completion: nil) or push in navigation controller self.navigationController!.pushViewController(MyViewController(nibName: “MyViewController”, bundle: nil), animated: true)
presenting ViewController with NavigationViewController swift
Calling presentViewController presents the view controller modally, outside the existing navigation stack; it is not contained by your UINavigationController or any other. If you want your new view controller to have a navigation bar, you have two main options: Option 1. Push the new view controller onto your existing navigation stack, rather than presenting it … Read more
Swift presentViewController
Try this: let vc = ViewController() //change this to your class name self.presentViewController(vc, animated: true, completion: nil) With Swift3: self.present(vc, animated: true, completion: nil)