【问题标题】:UITableViewCell with dropdown UITableViewUITableViewCell 与下拉 UITableView
【发布时间】:2018-05-25 04:09:41
【问题描述】:

我正在使用具有“n”行数的 UITableView。在每个单元格中,我都有一个菜单按钮。当我单击菜单按钮时,我需要在每个单元格中显示一个包含 3 行的下拉 UITableView。如何设置下拉 UITableView 的框架。我正在使用目标 c。

当我点击菜单按钮时,我需要在每个单元格的菜单按钮下方显示报告 UITableView

【问题讨论】:

标签: ios objective-c


【解决方案1】:

这有点复杂,但并不难。幸运的是,我们有一个名为 DropDown 的库。这使这项任务变得非常容易。

pod 'DropDown' 添加到您的 Podfile。

let dropDown = DropDown()

// The view to which the drop down will appear on
dropDown.anchorView = view // UIView or UIBarButtonItem in your case that menu button

// The list of items to display. Can be changed dynamically
dropDown.dataSource = ["Report"]

dropDown.selectionAction = { [unowned self] (index: Int, item: String) in
  print("Selected item: \(item) at index: \(index)")
}
dropDown.show()

在 Objective-C 中

DropDown *dropDown = [[DropDown alloc] init];
dropDown.selectionAction = ^(NSInteger, NSString * _Nonnull) {
    //code
};

Swift 中的库,但您可以使用桥接头在 Objective C 中使用它。 希望对你有帮助

【讨论】:

  • 你能在objective c中分享这个吗
  • 谢谢@Ganesh Manickam
  • 不客气。如果这解决了您的问题,您可以对此答案进行投票并将其标记为该问题的答案:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-03-13
  • 1970-01-01
  • 1970-01-01
  • 2015-05-13
  • 2021-12-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多