【问题标题】:cell.accessoryType = UITableViewCellAccessoryDetailButton WHAT IS NEXT?cell.accessoryType = UITableViewCellAccessoryDe​​tailButton 下一步是什么?
【发布时间】:2014-08-03 14:46:59
【问题描述】:

对于 iOS 来说还是相当新的。我设法编写了一个基本应用程序来显示文档列表/表格。我已经包括:

cell.accessoryType = UITableViewCellAccessoryDe​​tailButton;

在一个圆形按钮内显示一个蓝色 i,我猜它可以用来执行某种操作。

我现在想做的是,点击后,显示随后的屏幕,其中包含有关文档、按钮、添加、删除功能、日期、文件大小等信息...

这是通过 segue 还是其他方法完成的?

作为新手,我不确定下一步是什么。如果我知道必须采取哪些步骤才能到达下一个屏幕,我可以在网上搜索有关如何执行任何给定步骤的示例。

感谢您的帮助

【问题讨论】:

    标签: ios objective-c ios7


    【解决方案1】:

    accessoryButton 触发它自己的委托方法,与行选择不同,称为:

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

    将该方法添加到您的委托,然后执行 vc 转换。有几种方法可以进行这种转换,最常见的是discussed here...

    【讨论】:

      【解决方案2】:

      首先,欢迎来到 iOS 开发社区!

      为了做到这一点,我会使用 segue 到您可以设计的详细视图。当您使用 didSelectRowAtIndexPath 选择表中的一行时,您将为数组中被选择的对象设置一个 @property:self.selectedObject = self.tableviewarray objectAtIndex:indexPath.row;然后在 prepareForSegue 方法中,您可以获得目标视图控制器并执行 destinationViewController.myObject = self.selectedObject;现在详细视图知道要为哪个对象显示信息!

      【讨论】:

      【解决方案3】:

      您需要实现委托方法

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

      并相应地处理该回调中的行点击。

      一个例子是这样的:

      -tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath {
          YourObject *theModelForRow = [_itemList objectAtIndex:indexPath.row];
      
          YourViewController *someNewViewController = [YourViewController viewControllerWithModel:theModelForRow];
          [self.navigationController pushViewController:someNewViewController animated:YES];
      }
      

      【讨论】:

        猜你喜欢
        • 2013-12-27
        • 1970-01-01
        • 2013-11-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多