• 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: NSSegmentedControl & NSSegmentStyleSeparated & autolayout
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSSegmentedControl & NSSegmentStyleSeparated & autolayout


  • Subject: Re: NSSegmentedControl & NSSegmentStyleSeparated & autolayout
  • From: Ken Thomases <email@hidden>
  • Date: Wed, 26 Aug 2015 08:31:59 -0500

On Aug 26, 2015, at 7:04 AM, Jacek Oleksy <email@hidden> wrote:

> I want to set NSSegmentStyleSeparated on my NSSegmentedControl
> (managed by autolayout). However, when I create constraints for the
> parent view, I get an exception:
>
> Assertion failure in -[NSSegmentedControl ns_widgetType],
> /SourceCache/AppKit/AppKit-1348.17/Layout.subproj/NSUserInterfaceTheme.m:398
>
> An uncaught exception was raised
> What kind of segmented control are we!
>
> Example code:
>
> (in WindowController)
> - (void)windowDidLoad {
>    [super windowDidLoad];
>    NSSegmentedControl* segmentedControl = [[NSSegmentedControl alloc] init];
>    [segmentedControl setSegmentCount:2];
>    [segmentedControl setTranslatesAutoresizingMaskIntoConstraints:NO];
>    segmentedControl.segmentStyle = NSSegmentStyleSeparated;
>    [self.window.contentView addSubview:segmentedControl];
>    NSString* constraint = @"|-[segmentedControl]-|";
>    NSDictionary* views = NSDictionaryOfVariableBindings(segmentedControl);
>    NSArray* constraints = [NSLayoutConstraint
>                            constraintsWithVisualFormat:constraint
>                            options:NSLayoutFormatDirectionLeadingToTrailing
>                            metrics:nil
>                            views:views];
>    [self.window.contentView addConstraints:constraints];
> }
>
> The exception is raised in "addConstraints:".
> Everything is fine if I do not change segmentStyle. It also works fine
> if I change segment style *after* adding constraints, but then I get
> the exception e.g. when dragging window to external display.
>
> Any ideas?

This is a shot in the dark, but: does it help to initialize with -initWithFrame: instead of -init?  (You can pass NSZeroRect.)

Regards,
Ken


_______________________________________________

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: NSSegmentedControl & NSSegmentStyleSeparated & autolayout
      • From: Jacek Oleksy <email@hidden>
References: 
 >NSSegmentedControl & NSSegmentStyleSeparated & autolayout (From: Jacek Oleksy <email@hidden>)

  • Prev by Date: NSSegmentedControl & NSSegmentStyleSeparated & autolayout
  • Next by Date: Re: NSSegmentedControl & NSSegmentStyleSeparated & autolayout
  • Previous by thread: NSSegmentedControl & NSSegmentStyleSeparated & autolayout
  • Next by thread: Re: NSSegmentedControl & NSSegmentStyleSeparated & autolayout
  • Index(es):
    • Date
    • Thread