-
Notifications
You must be signed in to change notification settings - Fork 15
List Item Radio Button Widget
The widget is an extension of the List Item Title Widget. The primary purpose of this widget is to accept option inputs from user.
The widget provides APIs to configure the options list:
-
- (NSInteger)addOptionToGroup:(NSString*)optionName;
This function enables adding an option to the widget. The function returns the index of the option added. This can be used later to modify or remove the option from the group. -
- (void)removeOptionFromGroup:(NSInteger)optionIndex;
This function can be used to remove an existing option from the group using its index. -
- (NSInteger)count;
This function returns the number of options.
Example of the widget is RC Stick Mode List Item Widget
The UI elements can be customized to match the style of the user's application. The customizations can be done programmatically using the APIs.
List of the customization APIs
-
- (void)setTextColor:(UIColor *)textColor forState:(UIControlState)state;
- Set the color for the option text for the designated state, allowing for disabled or selected options to show a different color from non-selected or enabled options. -
- (void)setTabsBackgroundColor:(UIColor *)color;
- Set the background color for the tabs in the UISegmentedController. This color applies to all segments. iOS 13.0 and newer only. -
NSInteger selection;
- Current selection value. -
- (void)setEnabled:(BOOL)isEnabled;
- Enable or disable the radio control. -
- (void)setEnabled:(BOOL)isEnabled atOptionIndex:(NSInteger)optionIndex;
- Allow enabling or disabling individual segments of the UISegmentControl being used to display the radio group. -
- (BOOL)setOption:(NSString *)optionName atIndex:(NSInteger)optionIndex;
- Replace the displayed option string at the specified index with a new option string. -
- (void)setOptionTitles:(NSArray<NSString *> *)newTitles;
- Replace all existing options with the strings from the passed in array. -
- (void)setOptionSelectedAction:(RadioButtonOptionChanged)actionBlock;
- Set the RadioButtonOptionChanged action block which will be called when the selected radio option is changed. The action block will receive two parameters, the old selected index and the new selected index.
The widget provides hooks for users to add functionality based on state changes in the widget.
The List Item Edit Text Button widget provides the following hooks:
-
ListItemRadioButtonModelState
- Provides hooks in events received by the widget from the user interface interactions. It inherits ListItemTitleModelState and it adds no other hooks. -
ListItemRadioButtonUIState
- Provides hooks in events received by the widget from the user interface interactions. It inherits ListItemTitleUIState and it adds the following hook:
-
+ (instancetype)optionSelected:(NSInteger)optionValue label:(NSString*)optionLabel;
- Event sent when the option changes. OptionValue is the 0-based index for the options and optionLabel is the name of the option.
DJI UX SDK Version 5 Beta 4.1