WGViewController

open class WGViewController: UIViewController, NCWidgetProviding, WGDelegate

Your TodayViewController should inherit from WGViewController to implement WidGame’s functionalities.

Author

Matheus Felizola Freires
  • The SKView that will present your WidGame scenes.

    Declaration

    Swift

    open var gameView: SKView?
  • An enum that provides the reasons which your widget might close.

    Author

    Matheus Felizola Freires
    See more

    Declaration

    Swift

    public enum ExitReason
  • Declaration

    Swift

    open var isExpandable: Bool = true
  • Declaration

    Swift

    open var maxHeight:CGFloat = 359
  • Sets the widget expandability.

    Requires

    iOS 10.0

    Todo

    Create a fallback to versions earlier than iOS 10.0

    Author

    Matheus Felizola Freires

    Declaration

    Swift

    private func changeExpandability(to value: Bool)

    Parameters

    value

    A Bool value that tells the method if it should make the widget expandable or not.

  • Notifies the view controller that its view was removed from a view hierarchy.

    You can override this method to perform additional tasks associated with dismissing or hiding the view. If you override this method, you must call super at some point in your implementation.

    Declaration

    Swift

    open override func viewDidDisappear(_ animated: Bool)

    Parameters

    animated

    If true, the disappearance of the view was animated.

  • Sent to the view controller when the app receives a memory warning.

    Your app never calls this method directly. Instead, this method is called when the system determines that the amount of available memory is low.

    You can override this method to release any additional memory used by your view controller. If you do, your implementation of this method must call the super implementation at some point.

    Declaration

    Swift

    open override func didReceiveMemoryWarning()
  • Called when the widget is in a situation that it might be closed. An exit reason is provided to the method, so your logic can react accordingly.

    This method should be used for your save logic.

    The default implementation of this method is blank.

    Todo

    Find out if there are more things that might cause the widget to close.

    Author

    Matheus Felizola Freires

    Declaration

    Swift

    open func widgetMightClose(reason: WGViewController.ExitReason)
  • Notifies the container that the size of its view is about to change.

    WidGame uses this method to set some widget configurations and creating your game view. It is this method who calls the presentInitialScene() method.

    UIKit calls this method before changing the size of a presented view controller’s view. You can override this method in your own objects and use it to perform additional tasks related to the size change. For example, a container view controller might use this method to override the traits of its embedded child view controllers. Use the provided coordinator object to animate any changes you make.

    If you override this method in your custom view controllers, always call super at some point in your implementation so that UIKit can forward the size change message appropriately. View controllers forward the size change message to their views and child view controllers. Presentation controllers forward the size change to their presented view controller.

    • size: The new size for the container’s view.
    • coordinator: The transition coordinator object managing the size change. You can use this object to animate your changes or get information about the transition that is in progress.

    Declaration

    Swift

    open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator)
  • Override this method to show your first scene and load any saved info.

    The default implementation of this method is blank.

    Author

    Matheus Felizola Freires

    Declaration

    Swift

    open func presentInitialScene()
  • If you override the method below inside your TodayViewController, always call super at some point in your implementation so that WidGame can still update your gameView’s frame and tell your game scene about these updates.

    Declaration

    Swift

    open override func viewDidLayoutSubviews()
  • If you override the method below inside your TodayViewController, always call super at some point in your implementation so that WidGame can still delegate displayMode changes to your WGScene, and set the correct preferredContentSize to your widget.

    Declaration

    Swift

    open func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize)