gpt4 book ai didi

ios - 如何创建下拉弹出 View

转载 作者:行者123 更新时间:2023-11-28 12:13:29 52 4
gpt4 key购买 nike

我想在点击按钮时显示一个下拉菜单。我点击下面的链接。

https://richardallen.me/2014/11/28/popovers.html

但我的按钮在表格 View 单元格中,我想在按钮下方显示弹出窗口。我搜索了很多并通过使用弹出窗口找到了方法。但我不知道如何使用和显示它。如果我点击上面的链接,则会显示以下错误。弹出窗口会全屏显示。所以请帮助我。

/Base.lproj/Main.storyboard:%20Couldn't%20compile%20connection:%20<IBCocoaTouchOutletConnection:%200x7fc9f5fa6330%20(KPd-LK-kJS)%20source=<IBProxyObject:%200x7fc9f5fa6020%20(mgH-pb-OhC)%20'Placeholder%20for%20UIStoryboardPopoverPresentationSegueTemplate%20with%20OID%20qoG-n8-Yu0'>%20property=anchorView%20destination=<IBUIButton:%200x7fc9f796dd40%20(xk1-Vu-vnj)%20'Anchor%20View'>>

提前致谢。

最佳答案

使用 tableview 和 popover 创建下拉列表有点耗时,但幸运的是我们有一个替代解决方案,使用这个 library非常容易使用

初始化:

let dropDown = DropDown()

// The view to which the drop down will appear on
dropDown.anchorView = view // UIView or UIBarButtonItem

// The list of items to display. Can be changed dynamically
dropDown.dataSource = ["Car", "Motorcycle", "Truck"]

处理选择:

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

// Will set a custom width instead of the anchor view width
dropDownLeft.width = 200

显示操作:

dropDown.show()
dropDown.hide()

希望对你有帮助

关于ios - 如何创建下拉弹出 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47647367/

52 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com