【问题标题】:Is this normal behavior for UITableViewCellAccessoryDetailDisclosureButton这是 UITableViewCellAccessoryDe​​tailDisclosureButton 的正常行为吗
【发布时间】:2013-02-11 14:52:40
【问题描述】:

我注意到,当我设置 MessageTableViewCell accessoryType =UITableViewCellAccessoryDe​​tailDisclosureButton 并在“箭头按钮”本身上按标签时,didSelectRowAtIndexPath: 上声明的弹出菜单不显示向上??!!!如果我在单元格的其他区域(“箭头按钮”本身除外)上进行选项卡,它工作正常,

但是,如果我改用 UITableViewCellAccessoryDisclosureIndicator 单元格附件类型,它可以正常工作,即使我在箭头本身上加了标签。

我想知道这是正常行为、错误还是我做错了什么。

我更喜欢 UITableViewCellAccessoryDe​​tailDisclosureButton,因为在我看来,当你想引起用户的注意时,它会更清楚。

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

        MessageTableViewCell* cell = (MessageTableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil)
        {
            cell = /*[*/[[MessageTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] /*autorelease]*/;

        }
        CastNearAppDelegate *appDelegate = (CastNearAppDelegate *)[[UIApplication sharedApplication] delegate];


        Message* message = [appDelegate.dataModel messageWithID: indexPath.row];

        if (!message.isSentByUser)
        {
            cell.accessoryType =/*UITableViewCellAccessoryDetailDisclosureButton; */UITableViewCellAccessoryDisclosureIndicator;
        }else
        {
            cell.accessoryType = UITableViewCellAccessoryNone;
        }

        message.bubbleSize = [SpeechBubbleView sizeForText:message.text];

        [cell setMessage:message];

        return cell;
    }

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {




       UIActionSheet  *popupQueryOptions = [[UIActionSheet alloc]
                                          initWithTitle:@"Options for Blocking and Spam Reporting"
                                          delegate:self
                                          cancelButtonTitle:@"Cancel"
                                          destructiveButtonTitle:@"Block Sender"
                                          otherButtonTitles:/*@"Block Sender",*/
                                          @"Inappropriate Content",
                                          /*@"Tell a Friend via Facebook",
                                           @"Tell a Friend via Twitter",*/
                                          nil];

        popupQueryOptions.actionSheetStyle = UIActionSheetStyleBlackOpaque;

        [popupQueryOptions showInView:[UIApplication sharedApplication].keyWindow];


}

【问题讨论】:

标签: ios objective-c xcode ios6


【解决方案1】:

它们用于不同的事情。指示器只是一个指示器,而按钮允许您执行不同的操作,例如就像一个按钮。

UITableView 有两种可能的方法,当点击单元格时它会调用它的委托。

当行本身被点击时,会调用以下内容

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

当你点击附件时,tableView 会调用

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath

您也可以在 Interface Builder 中独立连接它们。所以这种行为是相当蓄意的。

【讨论】:

    【解决方案2】:

    当您使用公开按钮时,会调用委托方法 tableView:accessoryButtonTappedForRowWithIndexPath: 而不是 tableView:didSelectRowAtIndexPath:

    显示按钮通常用于单元格的某种辅助操作,例如在 Wifi 设置中,它显示网络选项,同时点击整个单元连接到它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多