IBOutlet is nil, but it is connected in storyboard, Swift

Typically this happens because your view controller hasn’t loaded its view hierarchy yet. A view controller only loads its view hierarchy when something sends it the view message. The system does this when it is time to actually put the view hierarchy on the screen, which happens after things like prepareForSegue:sender: and viewWillAppear: have returned. … Read more

In iOS13 the status bar background colour is different from the navigation bar in large text mode

No hacks or funkiness required here. The key is defining the desired appearance and setting this value on BOTH the nav bar’s standardAppearance AND its scrollEdgeAppearance. I have the following in the init for my base navigation controller subclass for my entire app: if #available(iOS 13.0, *) { let navBarAppearance = UINavigationBarAppearance() navBarAppearance.configureWithOpaqueBackground() navBarAppearance.titleTextAttributes = … Read more

Best practices for Storyboard login screen, handling clearing of data upon logout

In your appDelegate.m inside your didFinishLaunchingWithOptions //authenticatedUser: check from NSUserDefaults User credential if its present then set your navigation flow accordingly if (authenticatedUser) { self.window.rootViewController = [[UIStoryboard storyboardWithName:@”Main” bundle:[NSBundle mainBundle]] instantiateInitialViewController]; } else { UIViewController* rootController = [[UIStoryboard storyboardWithName:@”Main” bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@”LoginViewController”]; UINavigationController* navigation = [[UINavigationController alloc] initWithRootViewController:rootController]; self.window.rootViewController = navigation; } In SignUpViewController.m file … Read more

Programmatically set the initial view controller using Storyboards

How to without a dummy initial view controller Ensure all initial view controllers have a Storyboard ID. In the storyboard, uncheck the “Is initial View Controller” attribute from the first view controller. If you run your app at this point you’ll read: Failed to instantiate the default view controller for UIMainStoryboardFile ‘MainStoryboard’ – perhaps the … Read more

Passing Data between View Controllers in Swift

Let’s assumed we stand at the firstView go to the DetailView and want passing data from firstView to Detailview. To do that with storyboard, at the firstView we will have a method: override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) { if (segue.identifier == “segueTest”) { //Checking identifier is crucial as there might be multiple // segues … Read more

Displaying images on another view controller when button is clicked

Swift 4 First, add a notification in each button action: NotificationCenter.default.post(name: Notification.Name(“buttonAIsPressed”), object: nil) now add a notification listener in the viewDidLoad of the collection view class and call the function in the selector: NotificationCenter.default.addObserver(self, selector: #selector(self.YourFunctionName), name: Notification.Name(“buttonAIsPressed”), object: nil) now whenever a button is pressed the function you named will be called.