Re: How to constrain a UISlider in a UIToolbar?
Re: How to constrain a UISlider in a UIToolbar?
- Subject: Re: How to constrain a UISlider in a UIToolbar?
- From: Kyle Sluder <email@hidden>
- Date: Wed, 30 Jul 2014 08:49:59 -0700
> On Jul 30, 2014, at 7:44 AM, Roland King <email@hidden> wrote:
>
>
>> On 30 Jul 2014, at 2:30 pm, Gerriet M. Denkmann <email@hidden> wrote:
>>
>>
>>>
>>> Hmm, I'm pretty sure that’s all we override. Have you tried dropping our document title view into the toolbar and seeing what happens?
>>
>> No, I did not. It depends on OFBindingPoint et al., which might depend on other things, etc., etc.
>> But I studied it diligently.
>>
>> The problem (I guess) is that UIToolbar does not use LayoutConstraints at all. And it probably simply does not expect any of it's UIBarButtonItems to change their size.
>
> I think it’s because even though UIToolbar is a UIView subclass, UIButtonBarItem, which goes on it, isn’t.
Well, bar button items can have custom views, and sometimes non-view bar button items are encased in a view. So it’s definitely designed to work with views, and could be made to work with constraints.
> I never really understood why that was, it has that ‘NSCell’ code smell about it, feels like something done for efficient button bars in iOS 2.0 we’ll all suffer for forever.
The good thing about an abstracted API is that Apple could switch to one-view-per-bar-button-item tomorrow and none of us would know unless we looked.
> I assume that you kept the width of the button bar item which contains your custom view at the default of 0.0 right? It claims in that instance that the item sets the width to fit but I suspect that really only works if the content is a fixed icon and not a UIView.
That's the purpose of setting the auto-resizing mask to FlexibleWidth. At least for title views, that causes UINavigationBar to send -sizeThatFits: to the view.
>
> Can you pin a view over the top of the toolbar using constraints (they are both sibling UIViews after all) then pin your slider in there?
This might work visually, but make sure to get accessibility right.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden