Few questions on ContainerControl

I have a couple questions on the ContainerControl. Here is a brief idea of the scenario:

  • Container has labels for the question and answers 1-4. Also in the container are 4 canvases to the left of each answer which show as empty boxes initially and then a check mark when tapped to make a selection
  • The labels have the Left and Right AL properties set to Parent with Standard Gap, respectively. The 4 answers have the right set to Parent.Right - Standard Gap and left is to the right of the respective canvas plus Standard Gap. The labels are also set to BreakByWordWrapping
  • On the view, the Container is nestled in and takes up the whole screen, Right, Left, Top, and Bottom all set to zero for either Parent or Top/Bottom layout guide
  • The view also has 3 toolbar buttons: Save, Explain, and Next

Questions

  1. With the labels in the Container set as they are (with their AL properties), when run in simulator, they are not breaking by word wrapping. Instead, the text in the labels is one long stretch, and you have to scroll to the right to read the whole thing. The only way I was able to get these to break is by setting a set width to the label. I wanted to avoid this as the width will be smaller on some devices and larger on others. Thought AL would handle this correctly. Is there a way to get this to work? If necessary to just set a width, how can this be adjusted depending on the phone/iPad size?

  2. When I tap one of the canvases, the btnSave on the view should become active, btnExplain inactive, and btnNext inactive. When I click btnSave, btnSave inactive and btnExplain and btnNext are active. Click btnNext, all buttons inactive. Obviously the enabled = true/false can be handled in the ToolbarPressed in the view for all scenarios except the first. How do you make a call to a control on the view from a control in the container (tap canvas on container and make btnSave enabled)? I found this post (https://forum.xojo.com/38979-can-t-send-e-mail-from-container-in-build-app) and specifically the response from Michel (“Add a reference to the view as a property of the container. For instance myView as ViewSendMail which you initialize when you instantiate the container dynamically, or in the view Open if you dragged it onto the view.”). This only seems to work with methods on the view and not to modify controls. So how can you interact with a control on a view through a control on a container?

  3. When the labels word wrap appropriately in question #1 above, and if the questions and answers end up taking a lot of vertical real estate on container, is it possible to get the container to grow and shrink as necessary? For example, if the combined lines used up between the question and 4 answers is 20 lines for one question, and just 5 lines for another question, can the container grow as needed? In testing, I made the container very long, but when the text from the question and answers didn’t take up much space, there was still all that scrollable area. Also, I haven’t checked out all of the questions in the database (plus the user can increase the size of the text to make it read easier), so there can be some even lengthier than the height of the container.

Could you share an example project ?

Hi Jeremie,

I made a workaround with the question 2. For questions 1 and 3, I’d still like to know if there is an answer or if you have any assistance you can share.

Here is a sample project. I hope I did correctly. Never used dropbox before:
https://www.dropbox.com/s/lvy8yl8k7sgftom/ContainerLabelExample.xojo_binary_project?dl=0

For this sample, I used the example in the docs (iOS > Auto-Layout > AutoSizeLabel) and copied the label and button and also set the AL properties verbatim

  • Try this on iPhone 4s in the Simulator to get a feel for the smallest screen
  • You’ll see on the top of the view, is exactly from the Xojo example. The label works perfectly as expected, just like in the examples.
  • Below that is the ScrollableArea containing the ContainerControl
  • The first part of the CC is again the Xojo example verbatim (also the AL is exactly the same), but this time, you’ll see the label does not break. Instead it is just one long line
  • Clicking the button below this will touch on my question 3 above with the real estate. There are 4 labels with differing lengths of text. Some of my questions and answers in the db for the actual program will take up a lot of lengthy space, and others will not.
  • As I have it now (just so it works), I made the CC quite large. But this also means that when the Q and 4 As have only a line or two, there is still all that scrollable space. On the flip side, with those Q/As with much more text, the size of the CC should be adequate, but I haven’t yet identified the lengthiest ones to see if it all fits. Plus, I give the users the ability to change up the text size of the Q/As, so they might run out of space without being able to see all the possible choices

Make sense? Thanks for looking

I believe this is what you are trying to achieve:
https://drive.google.com/file/d/0B26uxse8_zgXUlUyV2RaaktNN0k/view?usp=sharing

Remember to always set a width (and height) to ContainerControls in a ScrollableArea.

After resizing the scrollable area, in your example by increasing the label’s height, you need to make a callback to setting the height at the iOSView level.

I have used this many times in my latest iOS app: https://itunes.apple.com/app/id1208312901?mt=8

Jeremie, you rock! Exactly what I wanted to accomplish. Thanks so much for your time!

Btw… I already downloaded Packr and am using it for some of our upcoming trips. Brilliant work! I’d love to know how you accomplished many of the features in the app, but I’m sure you had to rely on many declares, something I don’t know much about. Hopefully Xojo iOS will make great strides in time to include more needed features

Thanks again!
Ryan

Thanks Ryan,

To be completely honest, yes Packr did require a lot of declares to make it look that good and to set up some custom layouts.
However I would recommend adding iOSKit or XojoLib (both available on github) to all your iOS projects. Both libraries take care of 90% of the declares needed for Packr.

If you are making a public iOS app, you can also check github.com/jkleroy to include two free classes Xojo iRate and ThrottleSocket. One takes care of asking users for a rating on the Appstore, the other simulates slow network conditions.