Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No custom view support #11

Closed
andresteves opened this issue Sep 11, 2017 · 5 comments
Closed

No custom view support #11

andresteves opened this issue Sep 11, 2017 · 5 comments

Comments

@andresteves
Copy link

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

@Minitour
Copy link
Owner

@andresteves Hi, can you please show me the code that you tried?

@andresteves
Copy link
Author

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.

@Minitour
Copy link
Owner

Minitour commented Sep 11, 2017

@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.

@andresteves
Copy link
Author

andresteves commented Sep 11, 2017

For some reason the pod I had was version 1.0.2 which does not have that code..

@andresteves
Copy link
Author

andresteves commented Sep 11, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants