• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to constrain a UISlider in a UIToolbar?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: Thu, 31 Jul 2014 10:24:56 -0700

On Jul 31, 2014, at 10:05 AM, David Duncan <email@hidden> wrote:
>
>
>> On Jul 30, 2014, at 9:00 PM, Gerriet M. Denkmann <email@hidden> wrote:
>>
>>
>> On 31 Jul 2014, at 00:18, David Duncan <email@hidden> wrote:
>>
>>>> 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.
>>
>> Following your suggestion I changed my code to:
>>
>> override func viewWillLayoutSubviews()    //    manage slider in bottomToolBar
>> {
>>    //    current width of toolbar is all wrong. Need to do:
>>    bottomToolBar.setNeedsLayout()
>>    bottomToolBar.layoutIfNeeded()
>
> Assuming that you're in a typical case (the toolbar is the same width as your view) you can just use self.view.bounds.width instead of bottomToolBar.frame.size.width here. This is likely to be more robust

Really? This goes against my instinct… the desired result is that the slider take up a certain percentage of its superview. Therefore the computation should encode this relationship.

> (given that calling setNeedsLayout/layoutIfNeeded on the toolbar as you do above really should not change the toolbar’s size…).

This actually gets at a question I’ve had for a while—does -layoutIfNeeded resize the receiver, or only its subviews? I’m not sure the docs are explicit about this.

--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


  • Follow-Ups:
    • Re: How to constrain a UISlider in a UIToolbar?
      • From: David Duncan <email@hidden>
References: 
 >How to constrain a UISlider in a UIToolbar? (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: How to constrain a UISlider in a UIToolbar? (From: Kyle Sluder <email@hidden>)
 >Re: How to constrain a UISlider in a UIToolbar? (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: How to constrain a UISlider in a UIToolbar? (From: Kyle Sluder <email@hidden>)
 >Re: How to constrain a UISlider in a UIToolbar? (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: How to constrain a UISlider in a UIToolbar? (From: Roland King <email@hidden>)
 >Re: How to constrain a UISlider in a UIToolbar? (From: Kyle Sluder <email@hidden>)
 >Re: How to constrain a UISlider in a UIToolbar? (From: David Duncan <email@hidden>)
 >Re: How to constrain a UISlider in a UIToolbar? (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: How to constrain a UISlider in a UIToolbar? (From: David Duncan <email@hidden>)

  • Prev by Date: Re: How to constrain a UISlider in a UIToolbar?
  • Next by Date: Re: How to constrain a UISlider in a UIToolbar?
  • Previous by thread: Re: How to constrain a UISlider in a UIToolbar?
  • Next by thread: Re: How to constrain a UISlider in a UIToolbar?
  • Index(es):
    • Date
    • Thread