【问题标题】:UIButton not getting focus in uitableviewcellUIButton没有在uitableviewcell中获得焦点
【发布时间】:2013-11-27 09:43:53
【问题描述】:

我创建了带有不同按钮的自定义单元格,按钮总是正确地调用它们的动作,但我的问题是,如果我快速点击一个按钮,它不会突出显示,而是像我之前所说的那样调用它的动作。我需要慢慢点击几秒钟(1-2 秒)才能看到突出显示的状态。我认为这可能是因为首先它关注的是 tableview 的滚动视图,但我不知道如何解决这个问题。

请帮忙!

【问题讨论】:

  • 检查delaysContentTouches of tableviews scrollView
  • 尝试将tableview的delaysContentTouches设置为NO
  • 我试过了,但没有任何改变:S

标签: ios objective-c uitableview uibutton


【解决方案1】:

试试这个代码:使单元格选择类型为无

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
        {
            static NSString *CellIdentifier = @"Cell";

            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

            if (cell == nil) 
            {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
            }

            // Configure the cell...

             cell.selectionStyle = UITableViewCellSelectionStyleNone;

            return cell;
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多