Detecting sheet was dismissed on iOS 13

Is there a way to detect that the presented view controller sheet was dismissed? Yes. Some other function I can override in the parent view controller rather than using some sort of delegate? No. “Some sort of delegate” is how you do it. Make yourself the presentation controller’s delegate and override presentationControllerDidDismiss(_:). https://developer.apple.com/documentation/uikit/uiadaptivepresentationcontrollerdelegate/3229889-presentationcontrollerdiddismiss The lack … Read more

Given a view, how do I get its viewController?

From the UIResponder documentation for nextResponder: The UIResponder class does not store or set the next responder automatically, instead returning nil by default. Subclasses must override this method to set the next responder. UIView implements this method by returning the UIViewController object that manages it (if it has one) or its superview (if it doesn’t); … Read more

UIViewController viewDidLoad vs. viewWillAppear: What is the proper division of labor?

viewDidLoad is things you have to do once. viewWillAppear gets called every time the view appears. You should do things that you only have to do once in viewDidLoad – like setting your UILabel texts. However, you may want to modify a specific part of the view every time the user gets to view it, … Read more

Get to UIViewController from UIView?

Using the example posted by Brock, I modified it so that it is a category of UIView instead UIViewController and made it recursive so that any subview can (hopefully) find the parent UIViewController. @interface UIView (FindUIViewController) – (UIViewController *) firstAvailableUIViewController; @end @implementation UIView (FindUIViewController) – (UIViewController *) firstAvailableUIViewController { UIResponder *responder = [self nextResponder]; while … Read more

How to set Status Bar Style in Swift 3

[UPDATED] For Xcode 10+ & Swift 4.2+ This is the preferred method for iOS 7 and higher In your application’s Info.plist, set View controller-based status bar appearance to YES. Override preferredStatusBarStyle (Apple docs) in each of your view controllers. For example: override var preferredStatusBarStyle: UIStatusBarStyle { return .lightContent } If you have preferredStatusBarStyle returning a … Read more

Add a UIView above all, even the navigation bar

You can do that by adding your view directly to the keyWindow: UIView *myView = /* <- Your custom view */; UIWindow *currentWindow = [UIApplication sharedApplication].keyWindow; [currentWindow addSubview:myView]; UPDATE — For Swift 4.1 and above let currentWindow: UIWindow? = UIApplication.shared.keyWindow currentWindow?.addSubview(myView) UPDATE for iOS13 and above keyWindow is deprecated. You should use the following: UIApplication.shared.windows.first(where: … Read more

Disable the interactive dismissal of presented view controller

Option 1: viewController.isModalInPresentation = true (Disabled interactive .pageSheet dismissal acts like this.) Since the iOS 13, UIViewController contains a new property called isModalInPresentation which must be set to true to prevent the interactive dismissal. It basically ignores events outside the view controller’s bounds. Bear that in mind if you are using not only the automatic … Read more

Access Container View Controller from Parent iOS

Yes, you can use the segue to get access the child view controller (and its view and subviews). Give the segue an identifier (such as alertview_embed), using the Attributes inspector in Storyboard. Then have the parent view controller (the one housing the container view) implement a method like this: – (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { … Read more

Changing the Status Bar Color for specific ViewControllers using Swift in iOS8

After reading all the suggestions, and trying out a few things, I could get this to work for specific viewcontrollers using the following steps : First Step: Open your info.plist and insert a new key named “View controller-based status bar appearance” to NO Second Step (Just an explanation, no need to implement this): Normally we … Read more

Get top most UIViewController

presentViewController shows a view controller. It doesn’t return a view controller. If you’re not using a UINavigationController, you’re probably looking for presentedViewController and you’ll need to start at the root and iterate down through the presented views. if var topController = UIApplication.sharedApplication().keyWindow?.rootViewController { while let presentedViewController = topController.presentedViewController { topController = presentedViewController } // topController … Read more

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