Suggestion for UITextView is under floating header for UITableView
Asked Answered
C

2

7

I have floating headers for my UITableView (which I want). But it looks quite bad when the suggestion view for the UITextView in the cell above is under the header.

Seems like no one has had this problem before. Any suggestions?

Both the header cell and UITableViewCell is loaded from Xib.

The floating header have an alpha on its second topmost view so it's a bit see through.

Floating header is above suggestion dialog for UITextView

This is how it looks in "Debug View Hierarchy":

enter image description here

Cauvery answered 8/2, 2016 at 15:48 Comment(1)
I guess the correct way to solve it it to make the spelling-dialog show over the text rather then under it in this case. However, I think this is up to Apple to natively manage. I do not think there are APIs to fix this.Cauvery
H
5

What if you did something like 'pull' the UITextView out of the table when the user exits it. You could align it over the top and do a nice transition to the editing state perhaps with the table view showing through a blurred overlay or something, but that would allow you to take control of the editing state instead of having it mostly in the hands of the UITableView which was not really designed for multi-line editable cell content.

Hosiery answered 3/4, 2016 at 20:44 Comment(3)
Yes, this may be an alternative way of solving it. Seems a bit complicated though, what to happen if the user scrolls to see the beginning of the UITextView if it is to large to fit the screen?Cauvery
That's what I meant, take the text editing into its own modal state. It's a big change for a small problem but you risk whack-a-mole bug hunting otherwise. If you exhaust all other problems and you simply must have it fixed it might be worth a spike to get a feel.Hosiery
I found a simpler way. When I start focus in a cell I set the opacity of the background of the headercell below to 0. This will make it look like it's above. This only works since the background of the entire tableview is the same color as the header views.Cauvery
D
4

What if you send that UITextView to the front of the stack?

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/index.html#//apple_ref/occ/instm/UIView/bringSubviewToFront:

I suspect that if it is behind the view below it, that the autocorrect view may also obey the view index of the UITextView.

Departmentalism answered 30/3, 2016 at 11:59 Comment(4)
Nope, does not help. I guess this is as the textview is in the cell and moving it up with bringSubviewToFront: does only move it relative other subviews in that cell.Cauvery
Is that floating header view a custom view for a section header?Departmentalism
One more zIndex thing to try... What if you do this theView.layer.zPosition = MAXFLOAT; That is the only other thing I can think of that will bring the rendering of that layer to the top (still not sure if the autocorrect window will honor this though.Departmentalism
Did not help. Tried -MAXFLOAT as well.Cauvery

© 2022 - 2024 — McMap. All rights reserved.