Callbacks

The contentDock SDK contains various callback functions, which we also recommend for development. Get to know the callback functions below:

  • layoutSubviews
  • willRotateTo
  • didRotate

layoutSubviews

This callback is called when you want to update your Your element, e.g. because the iPad or iPhone was rotated from landscape to portrait. See also the callback willRotateTo.

Example for layoutSubviews
import UIKit
import CDockFramework

@objc(CustomElementsFunctionsSwift)

class CustomElementsFunctionsSwift: NSObject {

    @objc class func layoutSubviews(_ elementView: UIView) {
        // Your individual source code
        // ...

    }
}

As parameter you get a standard UIView object. For more information, see Apple Developer Documentation | UIView Class.


willRotateTo

This callback is called before the iPad is rotated to landscape or portrait and tells you the rotation will start. Here you can prepare for the rotation all your sub-elements that you have in your functions.

Example for willRotateTo
import UIKit
import CDockFramework

@objc(CustomElementsFunctionsSwift)

class CustomElementsFunctionsSwift: NSObject {

    @objc class func willRotateTo(_ orientation: NSNumber) {
        if let newOrientation: UIInterfaceOrientation = UIInterfaceOrientation(rawValue: orientation.intValue) {
            if newOrientation == .landscapeLeft || newOrientation == .landscapeRight {
                // Your individual source code
                // ...
            }
        }
    }

}

After that the callback layoutSubviews is called up, so that you can update your Your Element.


didRotate

This callback is called when the iPad is rotated to landscape or portrait and informs you that the rotation is finished. You can also update all your sub-elements that you have in your functions here.

Example for didRotate
import UIKit
import CDockFramework

@objc(CustomElementsFunctionsSwift)

class CustomElementsFunctionsSwift: NSObject {

    @objc class func didRotate() {
        let orientation = UIApplication.shared.statusBarOrientation
        if orientation == .landscapeLeft || orientation == .landscapeRight {
            // Your individual source code
            // ...
        }
    }

}

More information


Feedback or Questions

We are always happy to help you with questions about the code or other questions.

Was this page helpful? Yes No

Topics on this page