TableView在弹出窗口中的Swift

问题描述 投票:-1回答:1

请有人告诉我,我是否可以在弹出视图中放置一个tableView。我一直在使用PopupDialog中名为showStandardDialog的函数,这里有一些代码:

func showStandardDialog(a: String, b:String) {

    // Prepare the popup
    let title = "¡ INFORMACIÓN !"
    let message = "this is " +  a + "and this is " + b 

    // Create the dialog
    let popup = PopupDialog(title: title, message: message, buttonAlignment: .horizontal, transitionStyle: .zoomIn, gestureDismissal: true) {
        print("Completed")
    }

    // Create first button
    let buttonOne = CancelButton(title: "CANCEL") {
    }

    // Create second button
    let buttonTwo = DefaultButton(title: "OK") {
    }

    // Add buttons to dialog
    popup.addButtons([buttonOne, buttonTwo])

    // Present dialog
    self.present(popup, animated: true, completion: nil)
}

但我不知道如何使用相同的功能和库发送列表。

谢谢大家 :)

ios swift uitableview popup
1个回答
1
投票

PopupDialog是第三方库,如果你需要超级自定义的东西,你应该考虑自己做。

如果你想使用这个lib,那就看看如何完成RatingViewController in the examples

//
//  RatingViewController.swift
//  PopupDialog
//
//  Created by Martin Wildfeuer on 11.07.16.
//  Copyright © 2016 CocoaPods. All rights reserved.
//
import UIKit

class RatingViewController: UIViewController {

    @IBOutlet weak var cosmosStarRating: CosmosView!

    @IBOutlet weak var commentTextField: UITextField!

    override func viewDidLoad() {
        super.viewDidLoad()

        commentTextField.delegate = self
        view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(endEditing)))
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @objc func endEditing() {
        view.endEditing(true)
    }
}

extension RatingViewController: UITextFieldDelegate {

    func textFieldShouldReturn(_ textField: UITextField) -> Bool {
        endEditing()
        return true
    }
}

没有理由不能在xib中添加TableView,并且在ViewController中包含必要的委托和数据源。

© www.soinside.com 2019 - 2024. All rights reserved.