UIPasteControl still asks for permission when it's not the first one on the screen.

I'm trying to tame UIPasteControl on the screen where I have multiple textfields and each is having a paste button.

To comply with iOS 16 I'm changing my buttons to UIPasteControl.

This is a storyboard based UIKit screen with a controller written in swift.

I added UIPasteControl #1 with target of a textfield above it, and it works as expected.

I added UIPasteControl #2 with target of a textfield above it, and when I tap on that second UIPasteControl, it asks for the permission, per image attached.

I'm quite confused and I have double checked everything for my own error. Everything looks alright, except for that second UIPasteControl raising this permission popup. The first UIPasteControl never raises the popup.

This is on a real device running iOS 16 RC, Xcode Version 14.0 (14A309).

What I can be missing? What I can try?

The UIPasteControl is sensitive to items being drawn close to it. Best to try moving it away from the two text fields. If you still get this alert, please submit a minimal project that demonstrates the alert via FBA. Thanks!

glow

Thank you glow!

Indeed. This would explain the problems I'm seeing. I redesigned the screen to only have one Paste control on it and it is placed in the dedicated cell with only a help label below it. Even when sizing that dedicated UIPasteControl - until it stopped "touching" the neighbour controls, it was asking for the permission. I can see the point in avoiding obscuring its parts.

How can we define the UIPasteControl sizing requirements properly to be sure to give it enough space? I'm trying its intrinsic size and it always returns as zero rect. I'm trying to achieve its size predictability via minimumContentSizeCategory and maximumContentSizeCategory, so it has a predictable size for the different accessibility text sizes.

What's the correct way of placing/sizing this control in a storyboard with auto layout?

The example here:

https://developer.apple.com/documentation/uikit/uipastecontrol?changes=_5

Suggests:

pasteButton.frame = CGRect(x: view.bounds.width/2.0, y: view.bounds.height/2.0, width: 150, height: 60)

Is it something considered the safe dimensions for the UIPasteControl for all of the accessibility text sizes? Width of 150 doesn't seem to be "safe" - the whole UIPasteControl may not be even shown or it might be raising the permission alert, if the control itself shows.

Is it something that needs to be embedded into SwiftUI? Or would it work well in some sort of a container like UIStackView, would this one size it properly for all of the accessibility text sizes?

Some pointers would be appreciated so we can build future-proof designs that would not break easily.

Testing this control was exhausting because I couldn't predict the results. Combining it with the original UI was an even more complicated issue.

I really wanted a permission control like Photo Library.

UIPasteControl does have intrinsicContentSize but this starts out at size zero and then updates asynchronously to its final value, due to the design of the control. Autolayout then adapts all its dependent controls appropriately.

You will get best results if you do not force its actual size to smaller than intrinsic content size, so e.g. constraining the center only to something else, or constraining the width to some larger value. That being said, it will allow for a little squeezing.

If you want to embed this in SwiftUI, use PasteButton instead which is backed by UIPasteControl.

glow

UIPasteControl still asks for permission when it's not the first one on the screen.
 
 
Q