ios 6 - 在 UITableViewController 上没有调用 canperformaction [英] ios 6 - canperformaction not getting called on UITableViewController

查看:41
本文介绍了ios 6 - 在 UITableViewController 上没有调用 canperformaction的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力添加自定义共享菜单.我按照这个 stackoverflow post 来实现这个也看到了其他一些帖子.

I am working on adding custom shared menu. I followed this stackoverflow post to implement this also seen some other posts.

它正在正常工作.但是当我通过 UITabBar 项目操作进入这个 UITableView 控制器时,我遇到了被调用 canPerformAction 的问题,该操作将我导航回这个视图.

It is working as it should be. But I am getting problem to get called canPerformAction when coming on this UITableView Controller by UITabBar item action which navigate me back to this view.

我试图通过使用 之一解决这个问题在 stackoverflow 上回答.但是在这种情况下仍然没有调用 canPerformAction

I tried to sovle this problem by using one of the answer on stackoverflow. But still canPerformAction not getting called in this case

在这种情况下,任何帮助都是值得的.谢谢

Any help in this case is appritiated. Thanks

我的代码看起来像:

在 viewDidLoad 上,我正在执行以下操作

On viewDidLoad, i am doing following

UIMenuItem *sendByEmailMenuItem = [[UIMenuItem alloc] initWithTitle:@"Send e-mail" action:@selector(sendEmail:)];
[[UIMenuController sharedMenuController] setMenuItems: @[sendEmailMenuItem]];
[[UIMenuController sharedMenuController] update];

这些是我使用过的委托方法

These are delegate methods i have used

- (BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}
- (BOOL)tableView:(UITableView *)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {
    return NO;
}
- (void)tableView:(UITableView *)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {

}

- (BOOL) canPerformAction:(SEL)action withSender:(id)sender {
    return (action == @selector(sendEmail:));
}

- (BOOL)canBecomeFirstResponder {
    return YES;
}

- (void) sendEmail: (id) sender {
       //do stuff
}

推荐答案

已修复此问题.如果有人需要,请发布.

Fixed this issue. Posting it if some one needs it.

我在 shouldShowMenuForRowAtIndexPath 动作上添加了一个成为第一个响应者的调用

I have added a call to become fist respoder on shouldShowMenuForRowAtIndexPath action

- (BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath {
    [self becomeFirstResponder];
    return YES;
}

这解决了我的问题.谢谢

This fixed my issue. Thanks

这篇关于ios 6 - 在 UITableViewController 上没有调用 canperformaction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆