No custom view support
andresteves opened this issue · 5 comments
Hi,
It seems there is no support for adding a custom view...
I tried to add a custom view within the code but it does not show anything.
Regards,
Andre
@andresteves Hi, can you please show me the code that you tried?
Hi @Minitour
I tried the master branch with the readme custom code but some variables don't exist anymore.
So I tried to add a custom view to the existing stackview but with no success... Just displays a massive button.
@andresteves
Here is how you properly add a custom view:
//create the dialog object
let dialog = AZDialogViewController(title: "TableView Dialog", message: nil)
//make a ref to the container (the container where you place your custom views)
let container = dialog.container
//set a height for the container using a ratio. The ratio that is given describes how the height should
//be treated in respect to the width of the dialog. so in example "1.0" will result in a square container.
//A ratio of 0.2 means that the height of the container is 20% of the width of the dialog.
//The default value is "0.0" - which means hidden
dialog.customViewSizeRatio = 1.0
//add your custom views
let tableView = UITableView(frame: .zero, style: .plain)
container.addSubview(tableView)
/*
Do any additional setup to the view if you wish.
*/
//Add constraints; This step is very important.
/*
Visual representation of the constraints we are adding:
H: |-(0)-[tableView]-(0)-|
V: |-(0)-[tableView]-(0)-|
*/
tableView.translatesAutoresizingMaskIntoConstraints = false
tableView.topAnchor.constraint(equalTo: container.topAnchor).isActive = true
tableView.bottomAnchor.constraint(equalTo: container.bottomAnchor).isActive = true
tableView.leftAnchor.constraint(equalTo: container.leftAnchor).isActive = true
tableView.rightAnchor.constraint(equalTo: container.rightAnchor).isActive = true
//finally when ready, show the dialog
dialog.show(in: self)
If you are still unable to get it to work let me know.
For some reason the pod I had was version 1.0.2 which does not have that code..
Thank you for the code @Minitour.
For future reference replace
tableView.topAnchor.constraint(equalTo: container.topAnchor).isActive = tableView.bottomAnchor.constraint(equalTo: container.bottomAnchor).isActive = true
with
tableView.topAnchor.constraint(equalTo: container.topAnchor).isActive = true
tableView.bottomAnchor.constraint(equalTo: container.bottomAnchor).isActive = true