【发布时间】:2016-12-30 13:42:00
【问题描述】:
我正在尝试使用 github 扩展 (https://github.com/Orderella/PopupDialog) 将信息传递给我的自定义 PopUpViewController。 Popup 使用了一个我命名为 PopUpViewController 的视图控制器(带有一个 xib 文件),并且启动 PopUp 的视图控制器称为 MainViewController。
传递给 PopUpViewController 的信息将是一个 String 类型的数组(命名为:popUpArray),用于在一个表(命名为:tableView)中显示包含的信息。
MainViewController 代码:
func showCustomDialog(_ sender: UIButton) {
// Create a custom view controller
let PopUpVC = PopUpViewController(nibName: "PopUpViewController", bundle: nil)
// Create the dialog
let popup = PopupDialog(viewController: PopUpVC, buttonAlignment: .horizontal, transitionStyle: .bounceDown, gestureDismissal: true)
// Create second button
let buttonOne = DefaultButton(title: "Ok", dismissOnTap: true) {
}
// Add buttons to dialog
popup.addButton(buttonOne)
// Present dialog
present(popup, animated: true, completion: nil)
}
PopUpViewController 代码:
import UIKit
class PopUpViewController: UIViewController {
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var tableView: UITableView!
【问题讨论】:
-
你必须使用协议委托来传递信息。