【问题标题】:Problem presenting a UIActionSheet from a double tap in UITableViewCell在 UITableViewCell 中双击显示 UIActionSheet 时出现问题
【发布时间】:2010-07-23 02:52:35
【问题描述】:

当用户双击我的单元格时,我正在呈现 UIActionSheet:

在 Cell Init 中点击识别:

UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc]
                                            initWithTarget:self 
                                             action:@selector(handleDoubleTap:)];

        [doubleTap setNumberOfTapsRequired:2];
        [self addGestureRecognizer:doubleTap];
        [doubleTap release];

告诉代表处理水龙头:

- (void)handleDoubleTap:(UITapGestureRecognizer *)recognizer {
    NSLog(@"double oo");
    [delegate handleDoubleTapp];
}

现在作为我的 UITableViewController 的委托将呈现 UIActionSheet:

-(void)handleDoubleTapp{

        UIActionSheet *actionSheet = [[[UIActionSheet alloc]
                                       initWithTitle:nil
                                       delegate:self
                                       cancelButtonTitle:@"Cancel"
                                       destructiveButtonTitle:nil
                                       otherButtonTitles:@"Reply", @"Retweet", @"Direct Message", nil] autorelease];    
        [actionSheet showInView:self.parentViewController.tabBarController.view];

    }   
}

我的 UITableViewController 正确实现了 UIActionSheet 委托方法。

问题:

  1. 并非操作表的所有区域都具有响应性
  2. 单击按钮会显示模式视图,但不会关闭操作表
  3. 当可以点击按钮时,它们不会突出显示

【问题讨论】:

    标签: iphone objective-c cocoa-touch uitableview uikit


    【解决方案1】:

    就像一个想法:您是否尝试在 UIActionSheet 即将变得可见时取消注册 UIGestureRecognizer 并在操作表被关闭时重新注册它?可能是识别器干扰了触摸。

    【讨论】:

    • 如何注销识别器?
    • 我添加了:[recognizer removeTarget:nil action:NULL];在句柄双击。这解决了问题,但是在我双击一个单元格后,我无法再次双击它。注销的正确地点在哪里?在哪里注册合适?
    • 我没有删除,而是将启用状态设置为 false。显示操作表后,在委托中重新启用它。很棒的提示。
    • 完美 - 我很高兴能够为您指明正确的方向。关于启用/禁用状态而不是添加/删除的好发现!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-19
    • 1970-01-01
    • 2017-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-01
    相关资源
    最近更新 更多