Buttons seem to be bound to background image and disabled

Hi. I’ve been noticing this on a few of my views. On some, I have a background image taking up the whole space on the view. There are buttons and other fields placed over this. When run, you can see the buttons and other fields, but the buttons seem to be disabled. I see in the designer, when I select one of the trouble buttons, there’s a red outline around the ImageView, telling me this must think it is part of the parent. I then dragged all the trouble items off to the side out of the entire view and used the Auto Layout guide to put them back in, thinking if I don’t drag them onto the ImageView, they shouldn’t think that is their parent. This was working ok for me yesterday (after doing the drag and replaced by AL), but then coming back in today and testing, the buttons have become inactive again and look to be part of the ImageView parent.

Is there a way to release them from the parent?

I never understood why Parent was read only in iOS, when it is setable in Desktop and Xojo Web.

What you describe would be extremely simple in Desktop with me.parent = Nil in the button Open.

I thought I had posted a feature request, but apparently not. Maybe time to do it.

In the meantime, maybe a declare could set Parent to nil. But I would not know where to start.

Setting the parent to NIL via declare would mean to release a subview from its parent UIView which results in it being released from memory. You’d need to attach it to another UIView (in that case the Xojo view itself) to keep it alive. You could do so with iOSLib where the control extension gives you access to the AppleView object (the UIView of the control itself) that knows the addsubview and removefromsuperview methods. But I wonder if this would really be a good solution …

How about not using an imageview but the backgroundcolor (!) property of the UIView. You can create a UIColor (called AppleColor in iOSLib) from a picture. In the case, it is tiled to fill the view. If you scale it to the view’s size before, you should have your background image without an extra control behind.

Or, second possibility, address the content property of the view’s CALayer. Here you can attach an image directly.

EDIT: And a third thought: It could be the exclusiveTouch property of the imageview that will not send touch events down its subview chain when it’s set to true. That’s changeable with iOSLib too.

Thanks Ulrich. I’m trying to find how this would be called in your latest update to iOSLib. I found the AppleColor. Just not sure how to implement on the view

If you want to try it with the color, and let’s say your Xojo view is called view1, try this in the open event of the view:

dim BGColor as new AppleColor (BGImage) // If you have an image BGImage in your project View1.AppleView.BackgroundColor = BGColor
If you go for the CALayer:

dim AppleBGImage as new appleImage (BGImage) View1.AppleView.Layer.Contents = AppleBGImage

Or 3rd way with an imageview:

ImageView1.AppleView.ExclusiveTouch = False

That is awesome! Works perfectly. So many great things in yours and Jason’s kits!

Old thread, I know, but it seems extremely similar to what I am trying to achieve in

Would the technique described above be adaptable to iOSContainerControl ?

I suppose I need IOSLib to access such elements as AppleView.Layer, right ? Do they exist for iOSContainerControl ?