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
How to use the dialog with a custom view controller? #80
Comments
Hey @RyanHop3, I am not entirely sure if I understand the question. So title, body and image can be either set at initialization or modified at "runtime". You should be able to put this logic in the presenting view controller. If you have logic that exceeds the capability of the standard view, you can always use a custom view controller. More info on this can be found at #66, for example. Cheers |
Sorry If I was vague and thanks for the reply. I am trying to add a table view to the popup to displaying some information but can't see to do so successfully. I tried creating a custom view controller and xib file like in the cosmos demo but the table view will not appear and cellForRowAtIndexPath is not getting called. Do you know if it is possible to add a table view to the popUp? Thanks, Ryan. |
Hey @RyanHop3, I have published an example project with a custom view controller containing a table view. Check it out at https://github.com/mwfire/PopupDialogCustomExample. Hope that helps :) |
Ah Excellent, thank you. One query about this; I have further added a label to the Popup to act as a title (called titleForLabel) but I can't seem to pass information to the PopupTableViewController to set the information for the title(the title is different depending on which button activated the Popup). In the host view controller function I have the following code: vc.cities = popupArray but in PopupTableViewController when I try to print the titleForLabel in ViewDidLoad() it returns nil. titleForLabel is declared as: public var titleForLabel: String? in PopupTableViewController. Can you see why this is the case (I have probably overlooked something) and how to pass the information to titleForLabel? Thanks for the help, Ryan. |
Hey @RyanHop3, hm, hard to tell. If possible, could you please share your demo project? Cheers |
I'm having issues trying to upload the project to dropbox.... Only 3 small lines of code are needed to test my problem: In PopupTableViewController:
and in then in ViewController: within
When this code is added I would expect print(titleForTable!) to return "Test Title" but instead it is returning nil. How can this issue be resolved or is there another to pass information to the Popup? Thanks, Ryan. |
You are trying to print Is that correct? |
How do I change the code to pass this information through to PopupTableViewController then (e.g. how is it done for the cities array)? The idea would be to add a |
Have a look at
|
But the information doesn't seem to be passing through to the custom view controller. How do I access the variable within the custom view controller? Thanks for your help and time by the way! |
Any update or solution for this? Thanks, Ryan. |
Hello Ryan, Here you are not specifying any xib file to be used, but i could use mine as it is used in the demo? best regards, Morgan |
Hi Morgan, Apologies, I was copying the comment of Martyn and adding my code to it, but forgot to add the nibName as PopupTableViewController. The rest of the code and my issue still stands though. Kind Regards, Ryan. |
Hey guys, I am out of town for a few days. Please provide a repo/download link to an example project showcasing the problem as requested. I was not able to reproduce it. Thanks! |
https://www.dropbox.com/s/3zh8w62irn59zsd/PopupDialogCustomExample-master%202.zip?dl=0 In this project I have tried to add the title as shown but it loads nil. |
@RyanHop3, I changed the code to your needs, you can find it here. As mentioned in my comment above, you cannot expect the title or cities to be anything else than nil in With Moreover, I recommend to not use fixed widths for views that should fill the PopupDialog. The width adjusts to the viewport. Running your code changes of the example, you can see in the console errors as of broken constraints. Please also note that these things are not connected to PopupDialog, but to the general use of the iOS framework. Cheers |
Hi Martyn, Thank you for fixing my issue, I am still new to swift and learning! All the best, Ryan. |
Hey @RyanHop3. Sure thing! 💯 |
Report
Environment
Please provide information on your development environment, so we can build with the same scenario.
Dependency management
If you are not using any dependency managers, you can remove this section.
Hi I was wondering if it is possible to pass information to the PopupViewController which can then be used in labels. I have three buttons in a view controller that all launch the same PopupViewController, but I want them to display different information in the labels etc. based on what button was selected, but I cannot seem to find a way to do this! e.g. if button 1 is selected, the label displays 'Button 1 was selected', if button 2 was selected then the label displays 'Button 2 was selected' etc.
The text was updated successfully, but these errors were encountered: