viewForBaselineLayout should work without Auto Layout

Originator:Justin.SpahrSummers
Number:rdar://12925641 Date Originated:2012-12-21
Status:Open Resolved:
Product:iPhone SDK Product Version:6.0
Classification:Enhancement Reproducible:Always
 
Summary:
Though not explicitly documented as such, -viewForBaselineLayout is intended only for use with Auto Layout, and should only be overridden, not invoked.

It'd be useful if baseline layout were possible even for applications not using Auto Layout, whether by choice (not wanting to use a constraint solver) or necessity (performance problems and API difficulties with AL). Conventional layouts typically use magic numbers to accomplish this, which is obviously suboptimal.

Steps to Reproduce:
Invoke -[UITextField viewForBaselineLayout] on a text field that has a non-zero baseline, and try to align a frame with the resulting view.

Expected Results:
The returned view matches the actual baseline of the text.

Actual Results:
The returned view in the attached sample app has a frame of CGRectZero. I've also seen it end up at (CGRectGetMaxY(bounds) - 1) for text that has a baseline much higher up, seemingly aligning with descenders instead of the baseline.

Comments

It's also worth noting that AppKit provides -[NSView baselineOffsetFromBottom], which is usable without Auto Layout and for the purposes described, so it wouldn't be unprecedented.

By Justin.SpahrSummers at Dec. 21, 2012, 8:32 p.m. (reply...)

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!