TopLayoutGuide and BottomLayoutGuide

When I set a text field Left side to left side of TopLayoutGuide (or left side BottomLayoutGuide) the field moves off the phone screen almost out of view. When I run the app the field appears to use the parent left side not the the left side of the TopLayoutGuide. What could I be doing wrong?

Top- and Bottom-LayoutGuides should only be used for top and bottom constraints.

What are you trying to achieve?

Good question. Was looking for another way to get tables to line up with other fields within the iPhone with the notch! Trying to avoid htmlviewer…
It looks like the Top & Bottom layout is adjusting for the notch so I thought I would set my left and right constraints to that I might get an easy fix but no such luck.

This might work:

Declare sub insetsContentViewsToSafeArea lib "UIKit" selector "setInsetsContentViewsToSafeArea:" (obj as ptr, value as boolean)

insetsContentViewsToSafeArea(table.handle, True)

(written from my phone, might not compile)

2 Likes

Thank you sir.

However the table itself actually take the “safe area” into account without this declare.
I am assuming the table in the second line of the declare is the iosmobile table name I am using.

I am trying to get the labels in the view to take the “safe area” into account.

Could I put labels in a container then use that as a reference instead of a table in the declare?

see attached.

I believe I found the solution for you.
It is a documented feature although it is not available directly in the Layout editor.

  1. I have put the labels in a container. And set the Left and Right auto-layout like this: (Notice that I named them “Left” and “Right”

  2. In the Container.Opening event I added this code:


//Disable Left and Right layout guides
self.Constraint("Left").Active = False
self.Constraint("Right").Active = False

//Now add two new layout guides relative LeftMargin and RightMargin
Dim left As New iOSLayoutConstraint(me, _
iOSLayoutConstraint.AttributeTypes.Left, _
iOSLayoutConstraint.RelationTypes.Equal, _
self, _
iOSLayoutConstraint.AttributeTypes.LeftMargin, _
1, _
0)
self.AddConstraint(left)


Dim right As New iOSLayoutConstraint(me, _
iOSLayoutConstraint.AttributeTypes.Right, _
iOSLayoutConstraint.RelationTypes.Equal, _
self, _
iOSLayoutConstraint.AttributeTypes.RightMargin, _
1, _
0)
self.AddConstraint(right)

And this is the result:

Bingo!

Thank you definitely looks good. Really appreciate your efforts!
Have a great weekend!

Well getting close but not quite there. The table is using a custom cell not sure if that matters.

This what I get I am sure I did something wrong…


And if you try setting the same type of constraints in the table cell?
Left margin and right margin

Yes tried that looks like the same result.

Another solution is to use iOSMobileTableExtended from @Antonio_Rinaldi
http://falcosoftware.com/xojo/

That will enable you to set a custom header in the table.

Yes I used before but switched when there was an issue because I did not need al the flexibility that his routine allows. But I might have to go back. His was working well!

The actual table cell has no where to add constraints like before

Was looking through some documentation and Apple has something called the “Safe Area” which I believe excludes the notch. Too bad that is not available in the Layout constraints. Would make this easier.

Anyway thanks for all the effort!

You can add your comments to this feedback case: feedback://showreport?report_id=67660

I created it right after you started showing the issues you had in your app.

64580 - Mobile CustomTable cell does not display correctly on iPhones with notch in screen in landscape mode.

Thanks I created one a while ago but the title is probably not correct. It appears the table is functioning ok its other elements in the screen that are not using “constraints” that the table is using.

thanks.