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: David Duncan <email@hidden>
- Date: Wed, 30 Jul 2014 10:18:52 -0700
> On Jul 30, 2014, at 8:49 AM, Kyle Sluder <email@hidden> wrote:
>
>> 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.
Just wanted to chime in to ask anyone interested in using constraints with bars (NavigationBar & Toolbar primarily) to please file bugs with the kinds of things you want to do.
>
>> 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.
Most people haven’t ;-).
>
>> 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.
For UINavigationBar you shouldn’t need to even set flexible width, just implement -sizeThatFits:. Unfortunately UIToolbar does not call -sizeThatFits: for the views of bar button items.
Gerriet, you can try setting the frame of the slider then calling -setNeedsLayout/-layoutIfNeeded on the toolbar to update the layout. If you do this within the standard layout callbacks it should go along with any animation that is already going.
>
>>
>> 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
--
David Duncan
_______________________________________________
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