I have a view with a UIScrollView, UIImageView for a background, and a UITextView. I have created several other views just like this and they all come out okay - with a background image and scrollable text but for some reason, now I can't make that work. Either my image overlaps all of the text so that I can't read it or the UITextView default background (white) shows up so that the user can't see the background image. What could be causing this problem?
A:
Do you use Interface Builder or build the views hierarchy in code?
In both cases you should make sure that the order of your views is correct.
In IB the view that you want to appear on top of all the rest has to be under the rest of the views.
In code, make sure that the text view is the last to be added to the hierarchy.
You could also use the next code in order to check if this is the problem:
[self.view bringSubviewToFront:textView];
Michael Kessler
2010-06-20 12:39:52
I have never really dealt with hierarchy before - if a view didn't look right I would just mess with the order a little bit and I could usually get it to work. Unfortunately, I still can't in this case. I tried your code in the "viewDidLoad" section but I am getting an error saying that textView is undeclared - I have never declared a UITextView in the past and it has still worked. Could that be part of the problem?
Rob
2010-06-20 13:59:16
@Rob, I supposed that you have a member of UITextView type that you've connected to the view in the Interface Builder. Anyhow, happy for you that you've solved this. I suggest you to explore few sample projects that Apple provides or go over a tutorial or 2...
Michael Kessler
2010-06-20 15:38:16
A:
Okay, it must have had something to do with choosing the delegate. I can't say that I completely understand how I fixed it but it had to do with declaring the delegate in IB.
Rob
2010-06-20 14:31:45