BigZaphod / Chameleon

Chameleon is a port of Apple's UIKit for iOS (and some minimal related frameworks) to Mac OS X.
http://chameleonproject.org/
BSD 3-Clause "New" or "Revised" License
3.45k stars 572 forks source link

Table accessoryView Doesn't Work with UITextField, UITextView #69

Open shannona opened 13 years ago

shannona commented 13 years ago

The accessoryView in tables is limited to UILabels and other classes that respond meaningfully to sizeThatFits: . If you instead try to use a UIView child, such as UITextField, the accessory ends up writing right over the main label because sizeThatFits: in UIView just returns the size that it's given.

It's the layoutSubviews method in UITableViewCell that does the wrong thing.

(Under iOS, a UIView in an accessoryView instead behaves as expected.)

BigZaphod commented 13 years ago

Are you sure the bug isn't perhaps just with UITextField's sizeThatFits: implementation? UILabel, etc. are all UIView subclasses as well.

On Oct 7, 2011, at 1:33 PM, shannona wrote:

The accessoryView in tables is limited to UILabels and other classes that respond meaningfully to sizeThatFits: . If you instead try to use a UIView child, such as UITextField, the accessory ends up writing right over the main label because sizeThatFits: in UIView just returns the size that it's given.

It's the layoutSubviews method in UITableViewCell that does the wrong thing.

(Under iOS, a UIView in an accessoryView instead behaves as expected.)

Reply to this email directly or view it on GitHub: https://github.com/BigZaphod/Chameleon/issues/69

shannona commented 13 years ago

UILabel has its own sizeThatFits: method, which is why it works. UITextField (and UITextView, which I also tested), just drop back to UIView's default method.

Whether the problem is the UIView method (return size;), that UITextField and UITextView don't have their own method, or that layoutSubviews does the wrong thing, I don't actually know--just that the behavior is different under iOS.

BigZaphod commented 13 years ago

Ok. Likely the real problem is that UITextView/UITextField don't have a sizeThatFits: implementation. Investigation will be necessary.

On Oct 7, 2011, at 2:40 PM, shannona wrote:

UILabel has its own sizeThatFits: method, which is why it works. UITextField (and UITextView, which I also tested), just drop back to UIView's default method.

Whether the problem is the UIView method, that UITextField and UITextView don't have their own method, or that layoutSubviews does the wrong thing, I don't actually know--just that the behavior is different under iOS.

Reply to this email directly or view it on GitHub: https://github.com/BigZaphod/Chameleon/issues/69#issuecomment-2327133

shannona commented 13 years ago

When I thought about it more, that's what made the most sense to me too.