swift - 可以创建一个出现在 View Controller 角落的 UITableView

标签 swift xcode uitableview uiviewcontroller uiscrollview

我想在 Todoist 应用程序(见下文)中找到一个表格 View 之后建模一个表格 View ,是否可以在没有额外框架的情况下做到这一点?如果是这样,我将如何去做呢? enter image description here

最佳答案

您可以使用 UITableView 创建 View Controller 并将其呈现为 UIPopoverPresentationController

let vc = UIViewController()

vc.modalPresentationStyle = .popover

vc.preferredContentSize = CGSize(width: 200, height: 200)

let popUp = vc.popoverPresentationController

popUp?.permittedArrowDirections = .up

popUp?.delegate = self

popUp?.sourceView = sender as! UIView  // here set the frame of the button that the arrow points to when popup is shown

present(vc, animated: true, completion: nil)

//

在您呈现弹出窗口的 vc 中,使其实现委托(delegate) UIPopoverPresentationControllerDelegate 并编写此方法

func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
    return .none
}

关于swift - 可以创建一个出现在 View Controller 角落的 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50399083/

相关文章:

iphone - 是否可以更改 UITableView 部分标题背景颜色

iphone - 将FirstResponder 重新分配给不再出现在屏幕上的UITableViewCell 上的UITextView

swift - 如何检测 SwiftUI 中的点击手势位置?

ios - 如何设置特定 UITableViewCell 的背景颜色

xcode - 无法下载崩溃信息

ios - 更新到XE2 Update 2后,Delphi/FPC代码不再在XCode下编译

ios - 从另一个 UIViewController 的 UITableView 获取 UITableViewCell

swift - 在 Swift 中从 XMPP 获取名册

ios - 无法使用类型为 '[NSObject : AnyObject]?' 的索引下标类型为 'String' 的值 Swift 错误

ios - 使用 NSMutableData iOS 进行键值观察