Variable View?

Can I embed a view within a view or container control on an ios App?

Can you clarify what you want? Maybe a picture or mockup?

essentially I have a 2D matrix of views. Control of the actual views content is determined by a segment bar at the top of the view and a list down the left side of the screen. So by selecting the segment and and element of the list you form a 2D matrix index into which view is displayed.

MyView = views(x,y)

Use parent & detail views on IPad. On iPhone you might need to do it differently since the screen is smaller you can’t do parent and detail.

Split view isn’t going to cut it for this.
Is there an example of how to embed controls on the fly in code at run time?

Yes, that example is shipped with Xojo. iOS -> controls -> Dynamic

[quote=402795:@Brian O’Brien]essentially I have a 2D matrix of views. Control of the actual views content is determined by a segment bar at the top of the view and a list down the left side of the screen. So by selecting the segment and and element of the list you form a 2D matrix index into which view is displayed.

MyView = views(x,y)[/quote]
Sounds like you might instead want to do your layouts on ContainerControls and then add/remove them on the views as needed.

So I’d have x*y container controls in my project and 1 ‘what’ on my view?

Silly suggestion: do it like some web sites do it…?

Create a view with the segmented control and a list as a base.
Duplicate that times with different controls in the working space.

The code in the list and segment is shared in a global method.
When a segment or list is chosen, use a select case to decide what view should be shown.
Store the chosen segment value and list item.
Display the correct view, setting the Segment value and the List’s ScrollTo value in the constructor.
because the segment and list are the same on all views, it looks like only the working area content has changed

It is better to place container controls in an iOSScrollView.

Then use this method in a module to place the container in the scroll view:

[code]Public Sub SetContentFullScreen(extends scroll as iosScrollableArea, content As iOSControl)

scroll.Content = content

Dim cons As iOSLayoutConstraint

//Center the cc

cons = New iOSLayoutConstraint(content, _
iOSLayoutConstraint.AttributeTypes.CenterX, _
iOSLayoutConstraint.RelationTypes.Equal, _
scroll, _
iOSLayoutConstraint.AttributeTypes.CenterX, _
1.0, 0)
cons.Active = True
scroll.AddConstraint(cons)

cons = New iOSLayoutConstraint(content, _
iOSLayoutConstraint.AttributeTypes.Width, _
iOSLayoutConstraint.RelationTypes.Equal, _
scroll, _
iOSLayoutConstraint.AttributeTypes.Width, _
1.0, 0)
cons.Active = True
scroll.AddConstraint(cons)


cons = New iOSLayoutConstraint(content, _
iOSLayoutConstraint.AttributeTypes.Height, _
iOSLayoutConstraint.RelationTypes.GreaterThanOrEqual, _
scroll, _
iOSLayoutConstraint.AttributeTypes.Height, _
1.0, 0)
cons.Active = True
scroll.AddConstraint(cons)

End Sub
[/code]

Showing and placing a container will then be done with this code:

Dim cc as new MyContainerControl
scrollView.SetContentFullScreen(cc)

Important note
ContainerControls Open and Close event don’t fire on iOS when they are initialized by code.

If your container needs some initialization do it in a Constructor method or some other method you call from your view.