
enable menus in table views?
#1
Posted 03 February 2012 - 04:18 AM
- (BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath;
- (BOOL)tableView:(UITableView *)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender;
- (void)tableView:(UITableView *)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender;
I have tried setting my UITableView delegate but the above methods never get called. Are there comparable methods for SCTableViewModelDelegate?
Thanks,
Don
#2
Posted 04 February 2012 - 03:15 PM

We're adding all these new iOS 5 specific methods to SCTableViewModelDelegate in STV 3.0. If you need this urgently, please tell me and I'll prepare you a patch for v2.2.0. Thanks!
#3
Posted 04 February 2012 - 08:31 PM
When it STV 3.0 coming out?
Thanks,
Don
#4
Posted 28 October 2015 - 01:10 AM
Hi all,
I know I'm resurrecting a very old thread but did any of these methods make it into STV 5.x? I can't find anything relevant in the documentation.
I'm having problems getting an UIMenuController to show up from a UILongPressGestureRecognizer on a SCCustomCell. I can get the UILongPressGestureRecognizer action to fire, but canBecomeFirstResponder and canPerformAction:withSender: are never called in my SCCusotmCell subclass. Is it that the default NO of tableView:shouldShowMenuForRowAtIndexPath: is stopping the UIMenuController showing? Anyone got this working? Any pointers?
#5
Posted 30 October 2015 - 12:05 AM
So I checked STV 5.x code and the UITableViewDelegate methods
- (BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath; - (BOOL)tableView:(UITableView *)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender; - (void)tableView:(UITableView *)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender;
aren't implemented :-(
Building my own version of STV 5.1.3 with those methods implemented, with shouldShowMenuForRowAtIndexPath: returning YES and canPerformAction: returning NO, and then using this SCCustomCell subclass:
- (instancetype)initWithCoder:(NSCoder *)decoder { if (self = [super initWithCoder:decoder]) { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ UIMenuItem *menuItem = [[UIMenuItem alloc] initWithTitle:@"My Menu Item" action:@selector(myItemAction:)]; [[UIMenuController sharedMenuController] setMenuItems:@[menuItem]]; [[UIMenuController sharedMenuController] update]; }); } return self; } -(BOOL)canPerformAction:(SEL)action withSender:(id)sender { if (action == @selector(myItemAction:)) { return YES; } // else return NO; } -(void) myItemAction:(id)sender { // do my action }
looks to be working OK :-)
Tarek, can I request these UITableViewDelegate are implemented in STV, and there's some STV block magic to disable default menu items if required, and to add custom items, and to respond to default and custom menu items.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users