Implementing ScrollView from Jason's iOSKit

myLabel.AppleView.Top = Y works OK, but myLabel.AppleView.Left will cause the labels to be centered??, and there seems to be no way to left-align it (I have tried Label1.TextAlignment = iOSTextAlignment.Left)

The problem can be illustrated with this code:
Dim Label1 As New iOSLabel
Me.AddControl(Label1)
Label1.Text = “x”
Label1.AppleView.Top = 20
Label1.AppleView.Left = 5

Dim Label2 As New iOSLabel
Me.AddControl(Label2)
Label2.Text = “xxxxxxxx”
Label2.AppleView.Top = 40
Label2.AppleView.Left = 5

That’s weird. It looks like the label’s frames are shrunk to their minimum. When you tint them with a backgroundcolor, you will see that their frame is only the size of the text which will always be centered.

I tried different ways including putting the labels besides the iOSView, removing them from their parent and adding them to the ScrollView, but with the same result. Setting the label’s frame doesn’t help either. Finally I put them on a colored rectangle and started the removefromsubview/addtosuperview sequence timer triggered later. Before, the rectangle is colored and I can scroll everything around. When the timer fires and copies only the rectangle (the labels being subviews of it, so they will be transferred too), the color dispappears and both labels center again. The controls simply lose a part of their properties when the are attached to the contentview.

Another attempt with a rectangle bigger than the iOSView containing both labels could be resized to be shown in full, but without the second label which was placed below the iOSView’s lower border.

I was about to write you I’m fully clueless, then I tried:

[code] dim myview as new AppleView (FoundationFrameWork.NSMakeRect (0,0,600,900))
myview.BackgroundColor = AppleColor.BlueColor // don’t need this. In case it’s Black without use ClearColor
AppleScrollViewer1.ContentView = myview
dim d as new AppleLabel (FoundationFrameWork.NSMakeRect (5,40,200,40))
d.Caption = “Testlabel”
myview.AddSubview d

dim d2 as new AppleLabel (FoundationFrameWork.NSMakeRect (5,90,200,40))
d2.Caption = “And another testlabel”
myview.AddSubview d2

dim d3 as new AppleLabel (FoundationFrameWork.NSMakeRect (5,800,200,40))
d3.Caption = “And another testlabel way below”
myview.AddSubview d3[/code]

which finally works but starts in a full-contentview magnification and the scrolling is not reliable, at least on iOS Simulator. it mostly works paged or via doubletap only.

I could imagine the reason this works at least somehow is some part of the Xojo controls goes out of scope and therefore lose some of the properties. Admittedly that’s just a wild guess. But have you tried buffering your iOSLabels somewhere to make them live longer than the open event? I had forgotten I do so in the stitch method of the scrollview. I buffer the original views in the ViewArray() property of AppleScrollView. Otherwise the attached views wouldn’t work.

BTW, in case you need to read some of the Scrollview properties it’s better to use the DidMoveToWindow event. During the Open event, some properties of the control have not been set.

Thank you Ulrich for all the time you have spent on this issue.

As I see it now, it’s not reasonable to belive that there’s a quick fix to have the ScrollView in iOSLib to work the way I need for my project.

I have used the day to test UIScrollView in UIKit, and it works good on the iPhone, but has some small problems, that I can live with, on the simulator. So I plan to stick with that until Xojo comes up with a ScrollView.

If you happen to come up with a brilliant solution in the near future, I might switch back :slight_smile:

Never mind, Jan. There’s no rivalry between me and Jason; you should use whatever suits you best. And with both libraries working together (I hope they still do; didn’t check the last version of iOSKit yet), you are not forced to use them alternatively.
Having read Jason’s remarks on ScrollViews in another thread here, I believe it will take some time to find out what’s going on. So better don’t wait for me!

FWIW, Jan: I think I found the problem. I accidentally included the layoutSubviews event which I shouldn’t have done. The system must call it on the instance to make the added subviews (re)draw. They were not, that’s why the borders of textfields didn’t appear and similar things. The stitched views did work because I copied the whole iOSView as master subview, and this one has its layoutSubview routine implemented. Will be fixed in the next release.

That’s interesting. Looking forward to test it.

Will be between Xmas and new year’s eve. I am still rebuilding the view subclasses and updating the documentation.

Well, a bit later than I thought, but I’ll add the userControl properties tomorrow and then be’ll able to upload soon:
https://github.com/UBogun/Xojo-iosLib/wiki/AppleScrollView

How stupid of me, @Jan: While the missing border of iOSLibTextFields was a missing event implementation, trying to put new TextFields on the new iOSLibScrolView made them resize from their center again. Which was ok from beginning on: It were their standard layoutconstraints keeping them centered and full autoresizing.
The following code makes them behave correctly:

[code] me.id.CreateContentView(800,2000)

dim tf as new iOSTextField
tf.Text = “TestTest”
tf.view.Left = 20
tf.view.top = 20
tf.TextAlignment = iOSTextAlignment.Left
tf.view.Height = 32
tf.view.AutoresizingMask = new AppleAutoresizingMask // which means “don’t autoresize”
tf.view.TranslatesAutoresizingMaskIntoConstraints = true
dim tf2 as new iOSTextField
tf2.Text = “TestTesttestetst”
tf2.view.Left = 20
tf2.view.top = 60
tf2.TextAlignment = iOSTextAlignment.Left
tf2.view.AutoresizingMask = new AppleAutoresizingMask
tf2.view.Height = 32

tf.view.Width= 150
tf2.view.Width = 150
tf2.view.TranslatesAutoresizingMaskIntoConstraints = true

me.id.ContentView.AddSubview tf.View
me.id.ContentView.AddSubview tf2.View
[/code]