iOS Layout issues with UITextView
| Originator: | tempelmann | ||
| Number: | rdar://16301839 | Date Originated: | 12-Mar-2014 |
| Status: | Open | Resolved: | |
| Product: | Xcode | Product Version: | 5.1 |
| Classification: | Bug | Reproducible: | always |
Summary: I am seeing several probably related isues after I used the "Master-Detail" template today and modified it to show a list of fonts, replacing the detail view's UILabel with a UITextView. One issue is that suddenly the UITextViews I've added to a View do not show their view attributes any more. Originally, they did, but now they're gone. Also, possibly related, I found that adding a UITextView to a view controller that descends from a navigation controller, gets the top margin metrics wrong somehow. And this effect has actually problems on iOS 7.1 but not on 6.1. It's all very odd, and I am not sure if I made a mistake here, so I can't even tell if they're separate issues or not. If you find they are unrelated, feel free to make separate issues out of these. Steps to Reproduce: Issue 1: See "view attribs not shown.PNG". Note that on the bottom right, there's a category "View", but nothing shows up under it. It should show attributes such as "hidden" and "opaque". Don't ask me how this came to be, though. The View attribs vanished gradually. First, they were still visible in the iPad storyboard, because I managed to check the "hidden" attribute there, at a time when the attribs were already gone from the iPhone storyboard. A bit later, they were also gone from the iPad storyboard, and I cannot even edit the "hidden" attribute now any more. Issue 2: See "bad prj - layout before removal of bad view.PNG", or open the project from "bad.zip" and view the iPhone storyboard, Detail view. It shows two sub views named "good" and "bad. Note that good originally appears properly aligned, i.e. the text starts right under the "Detail" navigation bar. Run this project on an iPhone or simulator, and in the list that appears, tap any font item. You'll see the detail view with the text properly starting at the top as intended. Now, back in the project on the iPhone storyboard, with the Detail View Controller selected, remove the "bad" view. Note how the good view's text jumps down significantly, as also shown in "bad prj - layout after removal of bad view.PNG". This suggests that the layout is wrong. And if you run this now on iOS 7.1, you will also see there that the text has moved down a bit, though one can tap and scroll it back to the top. Funny, though - if you run the same project on iOS 6.1, the text remains at the top. So, this might not be just a bug in Xcode but in iOS 7 or 7.1. I can't tell, I hope you can. So, at this point I've shown you that the top alignment of the text view is somewhat borked. I then tried to figure out how to fix this without needing that extra, otherwise unused, "bad" view. I eventually found the solution: I need to align the top of the UITextView not with the "Top Layout Guide" as the layout editor suggests, but with the entire main view's top. That leads to a misleading display in the layout editor, as seen in "confusing but working layout.PNG" (i.e. text view overlaps with the nav bar), but not, if I run this, the text aligns properly at the top again, on both iOS 6.1 and 7.1. The project "good.zip" shows this change as well. Attached files available here: http://files.tempel.org/Various/radar_16301839.zip ---- comment added a while later the same day ----- Oh jeez! Forget the part about the missing "View" attributes. That's a case of "bad new HI design from Apple" - designing a control that hides its contents without any visual indicator that it has hidden content unless you hover over it with the mouse is a really bad idea in my understanding. Oh well, stupid me for not seeing the obvious, I guess. So, discard that part under "Issue 1". The rest is still valid, however, for now.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!