Class
HSWidgetViewController
A view controller that specializes in managing a widget view.
Declaration
@interface HSWidgetViewController : UIViewController
Description
Subclass HSWidgetViewController to implement the primary view of the widget. It provides default behavior for various functionality allowing widget development to focus on implementing the content. It provides the following functionality:
- Implements the loadView to setup the unclipped view allowing content outside of the bounds to receive events.
- Implements the viewDidLoad to setup the editing view and accessories while providing customization via cornerRadius and calculatedFrame.
- Implements loading of classes and widget display info from Info.plist while also allowing dynamic overriding of the values.
- Allowing custom widget availability via isAvailable.
- (Required) Providing a way to specify the starting grid size of the widget.
- Provides default implementation for creating/managing the preference options.
- Allowing widgets to enable accessories such as Expand, Shrink and Settings. While automatically enabling settings accesosry when a valid preference options class is provided.
- Provides convenience methods for managing expanding and shrinking accessories.
- Provides default implementation for zoom animation view while allowing overridability.
When creating a subclass, minimumSize needs to be implemented so that widgets manager knows when to allow addition of the widget. You may override any of these methods; but if you do, be sure to invoke the super class implementation for consistency.
Topics
Widget Information
-
+ bundle
Get the bundle of the widget.
-
+ widgetDisplayInfo
Get the display information about the widget such as icon, name and creator.
Adding Widgets
-
+ isAvailable
Returns whether the widget is currently available for addition.
-
+ minimumSize
Gets the minimum size required to add the widget to page.
-
+ canAddWidgetForAvailableGridPositions:
Get whether the widget can be added for given available grid positions.
-
+ allowedInstancesPerPage
Return the number of allowed instances per page so that widget manager can restrict additional instances.
-
+ addNewWidgetAdditionalOptionsControllerClass
Specify the class used for the additional options during widget adding.
-
+ createOptionsFromController:withAvailableGridPosition:
Create options dictionary to use for widget addition for the given additional options controller and grid positions.
-
+ widgetSizeFromController:withAvailableGridPosition:
Get the widget size to use for widget addition for the given additional options controller and grid positions.
Initializing A Widget View Controller
-
- initForWidgetFrame:withOptions:
Initialize a newly allocated widget view controller with the specified widget frame and options.
Properties
-
widgetFrame
A structure that represents the current grid frame of the widget.
-
requestedSize
The requested view size for the widget.
-
_gridPositions
An array of grid positions that the widget current occupies.
-
cornerRadius
Corner radius of the content and editing view.
Delegate
-
_delegate
An object to manage widget changes and perform accessory events.
-
- _setDelegate:
Called to set the delegate object.
Calculate Frame
-
- calculatedFrame
Get the calculated frame to use for content and editing view.
Accessories
-
AccessoryType
Constants for specifying the accessory type.
-
- isAccessoryTypeEnabled:
Return whether the accessory of specified type should be enabled or not.
-
- accessoryTypeTapped:
Called when the accessory of specfied type was tapped.
Dynamic Sizing
- Adding Dynamic Size
-
- containsSpaceToExpandOrShrinkToGridPositions:
Return whether there is enough available space to expand or shrink to specified grid positions.
-
- containsSpaceToExpandOrShrinkToWidgetSize:
Return whether there is enough available space to expand or shrink to specified size structure.
-
- updateForExpandOrShrinkToGridPositions:
Update the widget to the specfied grid positions.
-
- updateForExpandOrShrinkToWidgetSize:
Update the widget size to the specfied size structure (also updates grid positions).
Adding Preferences
- Adding Basic Preferences
-
+ preferencesOptionsControllerClass
Specify the class used for the preferences for settings accessory.
-
widgetOptions
Stores the current options for the widget.
-
- options
Gets a copy of the current widget options.
-
- setWidgetOptionValue:forKey:
Setter for changing widget options.
Zoom Animation
-
ZoomAnimationViewStyle
Constants for specifying the animation view style used during zoom animation.
-
- viewStyleForZoomAnimaton
Get the zoom animationg view style to use.
-
- zoomAnimatingView
Get the view to use for zoom animation.
-
- clearZoomAnimatingView
Called at the end of zoom animation, allowing the widget to clean up any custom views if created.
Animation Constants
-
HSWidgetAnimationDuration
Constant for normal animation duration.
-
HSWidgetQuickAnimationDuration
Constant for quicker animation duration.
Notifications
-
HSWidgetAllWidgetsConfiguredNotification
Posted when all widgets are done being configured after a respring.
-
HSWidgetAvailableSpaceDidChangeNotification
Posted when grid space availability of the page changed.
-
HSWidgetEditingStateChangedNotification
Posted when editing state changed providing the new state in user info.