Explaining difference between automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars, edgesForExtendedLayout in iOS7

Starting in iOS7, the view controllers use full-screen layout by default. At the same time, you have more control over how it lays out its views, and that’s done with those properties: edgesForExtendedLayout Basically, with this property you set which sides of your view can be extended to cover the whole screen. Imagine that you … Read more

Prevent segue in prepareForSegue method?

It’s possible in iOS 6 and later: You have to implement the method – (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender In your view controller. You do your validation there, and if it’s OK then return YES; if it’s not then return NO; and the prepareForSegue is not called. Note that this method doesn’t get called automatically when triggering … 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

How to find topmost view controller on iOS

I think you need a combination of the accepted answer and @fishstix’s + (UIViewController*) topMostController { UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController; while (topController.presentedViewController) { topController = topController.presentedViewController; } return topController; } Swift 3.0+ func topMostController() -> UIViewController? { guard let window = UIApplication.shared.keyWindow, let rootViewController = window.rootViewController else { return nil } var topController = … Read more

Looking to understand the iOS UIViewController lifecycle

All these commands are called automatically at the appropriate times by iOS when you load/present/hide the view controller. It’s important to note that these methods are attached to UIViewController and not to UIViews themselves. You won’t get any of these features just using a UIView. There’s great documentation on Apple’s site here. Putting in simply … Read more

Instantiate and Present a viewController in Swift

This answer was last revised for Swift 5.4 and iOS 14.5 SDK. It’s all a matter of new syntax and slightly revised APIs. The underlying functionality of UIKit hasn’t changed. This is true for a vast majority of iOS SDK frameworks. let storyboard = UIStoryboard(name: “myStoryboardName”, bundle: nil) let vc = storyboard.instantiateViewController(withIdentifier: “myVCID”) self.present(vc, animated: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)