Hiding BoldChatViewController
This page describes how to present BoldChatViewController in an application.
If the view controller is presented in a tab or a navigation controller there is no need to deal with the removal of the item. The tab always holds the view controller constantly. The navigation controller presents a back button to leave the chat.
On the other hand if it is presented as modal, more actions need to be done to be able to hide the control. There are two ways to achieve this.
- If there is a navigation
controller presented, add a left navigation bar button to be able to hide the
modal.
- (void)presentChat { self.boldChatViewController = ...//create it or set up in a segue UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Hide" style:UIBarButtonItemStylePlain target:self action:@selector(hideModal)]; self.boldChatViewController.navigationItem.leftBarButtonItem = leftBarButtonItem; ...//present the view controller } - (void)hideModal { [self.boldChatViewController.parentViewController dismissViewControllerAnimated:YES completion:nil]; }
- If there is no navigation
controller around the view controller, use external actions.
External Actions
There are special buttons defined in view logics(see details in BoldChatViewController Customization):
BoldChatViewController
- mainExternalActionButton
- endExternalActionButton
- errorExternalActionButton
BCFormViewLogic
- formExternalActionButton
BCChatViewLogic
- formExternalActionButton
They have the corresponding IBActions:
BoldChatViewController
- mainExternalActionButtonPressed
- endExternalActionButtonPressed
- errorExternalActionButtonPressed
BCFormViewLogic
- formExternalActionButtonPressed
BCChatViewLogic
- formExternalActionButtonPressed
If the buttons are connected with the corresponding actions the corresponding callbacks are called on the BoldChatViewController.externalActions delegate:
@protocol BoldChatViewControllerExternalActions <NSObject>
- (void)boldChatViewControllerFormExternalActionPressed:(BoldChatViewController *)boldChatViewController {
}
- (void)boldChatViewControllerChatExternlanguage-calActionPressed:(BoldChatViewController *)boldChatViewController {
}
- (void)boldChatViewControllerMainExternalActionPressed:(BoldChatViewController *)boldChatViewController {
}
- (void)boldChatViewControllerErrorExternalActionPressed:(BoldChatViewController *)boldChatViewController {
}
- (void)boldChatViewControllerEndExternalActionPressed:(BoldChatViewController *)boldChatViewController {
}
The buttons are not on the views by default. To use the external actions:
- Add the external action buttons to the views there are defined.
- Connect them to the corresponding IBActions.
- Set the object to BoldChatViewController.externalActions to a class that implements BoldChatViewControllerExternalActions protocol.
These events can be used to hide the BoldChatViewController when there is no navigation controller presented.