• 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: "Gerriet M. Denkmann" <email@hidden>
  • Date: Wed, 30 Jul 2014 11:11:45 +0700

On 29 Jul 2014, at 22:14, Kyle Sluder <email@hidden> wrote:

>> On Jul 29, 2014, at 2:34 AM, "Gerriet M. Denkmann" <email@hidden> wrote:
>>
>> I have a UIToolbar which contains a UISlider, flanked by two flexible spaces.
>> I would like to have this slider to be as big as possible.
>> Setting it's width does not make sense, as the UIToolbar width changes, depending on device and orientation.
>>
>> And setting constraints on the slider seems to be impossible (Xcode 6 beta 4).
>>
>> Any ideas?
>
> You need to put your slider inside of a subclass of UIView whose implementation of -sizeThatFits: returns an appropriate value.

This sounds like an excellent idea.
Now my bottom UIToolbar looks like:
Flexible Space, ViewWithSlider, Flexible Space

ViewWithSlider is:

import UIKit

class ViewWithSlider: UIView
{
	init( coder: NSCoder )
	{
		let functionName = "-[ViewWithSlider initWithCoder] "
		println(functionName + "will call super")
		super.init(coder: coder)
	}

	override func updateConstraints()
	{
		let functionName = "-[ViewWithSlider updateConstraints] "
		println(functionName + "will call super")
		super.updateConstraints()
	}

	override func sizeThatFits( size: CGSize ) -> CGSize	//	never called
	{
		let functionName = "-[ViewWithSlider sizeThatFits \(size)] "
		let superSize = super.sizeThatFits( size )
		println(functionName + "super fits \(superSize)")
		return superSize
	}

	override func systemLayoutSizeFittingSize( size: CGSize ) -> CGSize	//	never called
	{
		let functionName = "-[ViewWithSlider systemLayoutSizeFittingSize \(size)] "
		let superSize = super.systemLayoutSizeFittingSize( size )
		println(functionName + "super fits \(superSize)")
		return superSize
	}
}

and it prints:
-[ViewWithSlider initWithCoder] will call super
-[ViewWithSlider updateConstraints] will call super

But nobody ever cares to call sizeThatFits or systemLayoutSizeFittingSize.

Overriding requiresConstraintBasedLayout and returning either YES or NO makes no difference.

Anything else I forgot to override?


Kind regards,

Gerriet.


_______________________________________________

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: Kyle Sluder <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>)

  • Prev by Date: Re: iOS 8 beta 4 messes with my TextView
  • 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