On 29 Jul 2014, at 22:14, Kyle Sluder <k...@ksluder.com> wrote:

>> On Jul 29, 2014, at 2:34 AM, "Gerriet M. Denkmann" <gerr...@mdenkmann.de> 
>> 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to