Input area
The Chat UI input area is managed by NCChatSessionInputBarControl, which integrates text input, voice, emoji, extension panels, and @mentions by default.
NCChannelViewController includes a built-in input area instance, typically accessed directly through chatSessionInputBarControl.
Configure input bar layout
The input bar supports multiple layout combinations, configurable through setInputBarType:style:.
Layout options
| Layout pattern | Enum value |
|---|---|
| Voice switch - Input box - Extensions | NC_CHAT_INPUT_BAR_STYLE_SWITCH_CONTAINER_EXTENTION |
| Extensions - Input box - Voice switch | NC_CHAT_INPUT_BAR_STYLE_EXTENTION_CONTAINER_SWITCH |
| Input box - Voice switch - Extensions | NC_CHAT_INPUT_BAR_STYLE_CONTAINER_SWITCH_EXTENTION |
| Input box - Extensions - Voice switch | NC_CHAT_INPUT_BAR_STYLE_CONTAINER_EXTENTION_SWITCH |
| Voice switch - Input box | NC_CHAT_INPUT_BAR_STYLE_SWITCH_CONTAINER |
| Input box - Voice switch | NC_CHAT_INPUT_BAR_STYLE_CONTAINER_SWITCH |
| Extensions - Input box | NC_CHAT_INPUT_BAR_STYLE_EXTENTION_CONTAINER |
| Input box - Extensions | NC_CHAT_INPUT_BAR_STYLE_CONTAINER_EXTENTION |
| Input box only | NC_CHAT_INPUT_BAR_STYLE_CONTAINER |
Example
- (void)viewDidLoad {
[super viewDidLoad];
[self.chatSessionInputBarControl
setInputBarType:NCChatSessionInputBarControlDefaultType
style:NC_CHAT_INPUT_BAR_STYLE_SWITCH_CONTAINER_EXTENTION];
}
To completely disable input, use NCChatSessionInputBarControlNoAvailableType.
Default input mode
Supported default input modes:
NCChatSessionInputBarInputTextNCChatSessionInputBarInputVoiceNCChatSessionInputBarInputExtention
controller.defaultInputType = NCChatSessionInputBarInputText;
Common input area properties
| Property | Description |
|---|---|
inputTextView | Text input field |
switchButton | Text/voice toggle button |
recordButton | Voice recording button |
emojiButton | Emoji button |
additionalButton | Extension panel button |
pluginBoardView | Extension panel view |
emojiBoardView | Emoji panel view |
draft | Current draft text |
maxInputLines | Maximum input lines (1-6) |
mentionedInfo | Parsed @mention information |
mentionedUserIdList | List of mentioned user IDs |
isMentionedEnabled | Whether @mentions are enabled |
Hide emoji button
self.chatSessionInputBarControl.inputContainerView.hideEmojiButton = YES;
To completely disable system emoji, set this on the channel view controller:
controller.disableSystemEmoji = YES;
Extension panel
The + panel in the input area is provided by NCPluginBoardView. The following built-in tags are exposed:
| Feature | Tag |
|---|---|
| Album | PLUGIN_BOARD_ITEM_ALBUM_TAG |
| Camera | PLUGIN_BOARD_ITEM_CAMERA_TAG |
| File | PLUGIN_BOARD_ITEM_FILE_TAG |
| Voice call | PLUGIN_BOARD_ITEM_VOIP_TAG |
| Video call | PLUGIN_BOARD_ITEM_VIDEO_VOIP_TAG |
| Voice input | PLUGIN_BOARD_ITEM_VOICE_INPUT_TAG |
| Business card | PLUGIN_BOARD_ITEM_CARD_TAG |
Add custom extension items
Avoid using tags in the 1XXX range to prevent conflicts with SDK reserved tags.
[self.chatSessionInputBarControl.pluginBoardView
insertItem:[UIImage imageNamed:@"plugin_custom"]
highlightedImage:[UIImage imageNamed:@"plugin_custom_highlighted"]
title:@"Custom"
tag:20001];
Insert at specific position
[self.chatSessionInputBarControl.pluginBoardView
insertItem:[UIImage imageNamed:@"plugin_custom"]
highlightedImage:[UIImage imageNamed:@"plugin_custom_highlighted"]
title:@"Custom"
atIndex:0
tag:20001];
Update and remove extension items
[self.chatSessionInputBarControl.pluginBoardView
updateItemWithTag:20001
normalImage:[UIImage imageNamed:@"plugin_custom_new"]
highlightedImage:[UIImage imageNamed:@"plugin_custom_new_highlighted"]
title:@"New entry"];
[self.chatSessionInputBarControl.pluginBoardView removeItemWithTag:20001];
Handle extension item clicks
- (void)pluginBoardView:(NCPluginBoardView *)pluginBoardView clickedItemWithTag:(NSInteger)tag {
if (tag == 20001) {
// Custom extension logic
return;
}
[super pluginBoardView:pluginBoardView clickedItemWithTag:tag];
}
@mentions and user selection
The input area exposes key interfaces for @mention functionality:
self.chatSessionInputBarControl.isMentionedEnabled = YES;
[self.chatSessionInputBarControl addMentionedUser:userInfo];
By default, typing @ in a group channel triggers the SDK's user selection flow. To use a custom user selection page, override this method in your channel view controller and call the appropriate block when the selection finishes or is cancelled:
- (void)showChooseUserViewController:(void (^)(NCChatUIUserInfo *selectedUserInfo))selectedBlock
cancel:(void (^)(void))cancelBlock;
For complete details about @mentions, see Message mentions.