-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Remove menu actions from inputToolbar.contentView.textView #1321
Comments
This would be awesome, but if memory serves, this is tied to how Apple has setup the hierarchy of things. |
Hey @lobyncev 😄 I'm cleaning up old issues and trying to finish the next release of the library. I'm sorry I don't have time to respond to all questions. I'm going to close this issue, but the community should feel free to continue the discussion. Other ways to get help:
|
I believe @wdcurry is correct. Unfortunately, I can't confirm right now. |
Hi guys! I found a way to add additional menu items to bubbles exclude inputToolbar.contentView.textView without touch any code of original JSQMessagesViewController. In my subclass (for example DemoMessagesViewController) I added a private category at the top class: /**
* Category for using private members to handle appearing menu by long tap
*/
@interface JSQMessagesViewController (Private)
@property (nonatomic, readonly) NSIndexPath *selectedIndexPathForMenu;
- (void)jsq_didReceiveMenuWillShowNotification:(NSNotification *)notification;
@end
@implementation DemoMessagesViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Register additional long tap menu actions
[JSQMessagesCollectionViewCell registerMenuAction:@selector(customAction:)];
}
#pragma mark - Private
- (void)jsq_didReceiveMenuWillShowNotification:(NSNotification *)notification {
// Setup menuItems for bubble cell
if (super.selectedIndexPathForMenu) {
[UIMenuController sharedMenuController].menuItems = @[ [[UIMenuItem alloc] initWithTitle:@"Custom Action"
action:@selector(customAction:)] ];
}
[super jsq_didReceiveMenuWillShowNotification:notification];
// Setup menuItems for input TextView
[UIMenuController sharedMenuController].menuItems = nil;
}
@end I tried any variants. But this one works for me. |
Thanks for the update @dterekhov ! Maybe the library can provide a method that clients can override? - (void)didReceiveMenuWillShowNotification:(NSNotification *)notification forIndexPath:(NSIndexPath *)indexPath; The private method can call this, and clients can override to do what you've done here. Would this work for you? Would you like to submit a PR for this? |
This would be very welcome.. |
@jessesquires Take a look at #1563.
|
Based on #1563 (a breaking change) going to bump this to v8.0 😄 |
Ok, but FWIW, it doesn't break anything. The protocol is optional and the behavior of one's menus is unchanged if you don't implement the new function. |
…iewController * 'master' of https://github.com/jessesquires/JSQMessagesViewController: (86 commits) ImageOptim on assets (jessesquires#1845) update changelog and spec for 7.3.4 Fix issue jessesquires#1583: Don't highlight cell outside message bubble (when long press) (jessesquires#1744) update changelog and version for 7.3.3 Updated `canPerformAction:withSender:` in `JSQMessagesComposerTextView` to call super (jessesquires#1664). Fixes jessesquires#1663. Update CHANGELOG and version nums for 7.3.2 fix KVO crash. close jessesquires#1631 formatting small fix regarding scrollToIndexPath (jessesquires#1642) close jessesquires#1640 Update CHANGELOG.md update CHANGLOG. bump version numbers Reverted jessesquires#1588 to fix jessesquires#1602 and fix jessesquires#1604. (jessesquires#1623) bump version numbers Update CHANGELOG.md provide default init values for JSQMessagesCollectionViewLayoutAttributes to prevent assertion. fix jessesquires#1338 follow up for jessesquires#1247 and jessesquires#1591. obfuscate private APIs. swizzle via +initialize copy attributes clean up fix keyboard hiding bug on iOS 9 (jessesquires#1307). fix jessesquires#1063 - cleanup from PR jessesquires#1281 - fix menu actions, close jessesquires#1321 - make notification methods public - partially apply changes from PR jessesquires#1563 ...
…nch3 * origin/master: (66 commits) ImageOptim on assets (jessesquires#1845) update changelog and spec for 7.3.4 Fix issue jessesquires#1583: Don't highlight cell outside message bubble (when long press) (jessesquires#1744) update changelog and version for 7.3.3 Updated `canPerformAction:withSender:` in `JSQMessagesComposerTextView` to call super (jessesquires#1664). Fixes jessesquires#1663. Update CHANGELOG and version nums for 7.3.2 fix KVO crash. close jessesquires#1631 formatting small fix regarding scrollToIndexPath (jessesquires#1642) close jessesquires#1640 Update CHANGELOG.md update CHANGLOG. bump version numbers Reverted jessesquires#1588 to fix jessesquires#1602 and fix jessesquires#1604. (jessesquires#1623) bump version numbers Update CHANGELOG.md provide default init values for JSQMessagesCollectionViewLayoutAttributes to prevent assertion. fix jessesquires#1338 follow up for jessesquires#1247 and jessesquires#1591. obfuscate private APIs. swizzle via +initialize copy attributes clean up fix keyboard hiding bug on iOS 9 (jessesquires#1307). fix jessesquires#1063 - cleanup from PR jessesquires#1281 - fix menu actions, close jessesquires#1321 - make notification methods public - partially apply changes from PR jessesquires#1563 ...
I want add custom menu action to JSQMessagesCollectionViewCell:
[JSQMessagesCollectionViewCell registerMenuAction:@selector(customAction:)]; (see in your demo code), then custom menu actions showing in content menu inputToolbar.contentView.textView.
How not showing custom action in inputToolbar.contentView.textView?
The text was updated successfully, but these errors were encountered: