From 7c2903739daaa28952fa5d9c323d8c22cf597af3 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 4 Aug 2016 01:18:12 -0400 Subject: [PATCH] Call -[DebuggerController updateSegmentControl] when the superview frame changes. --- Source/DebuggerController.m | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Source/DebuggerController.m b/Source/DebuggerController.m index 896980f..3a42310 100644 --- a/Source/DebuggerController.m +++ b/Source/DebuggerController.m @@ -96,17 +96,23 @@ forKeyPath:@"selection.source" options:NSKeyValueObservingOptionNew context:nil]; - [[_segmentControl cell] addObserver:self - forKeyPath:@"selectedSegment" - options:NSKeyValueObservingOptionNew - context:nil]; self.connection.autoAttach = [attachedCheckbox_ state] == NSOnState; _breakpointsController = [[BreakpointController alloc] init]; [[self.tabView tabViewItemAtIndex:1] setView:_breakpointsController.view]; + // When the segment control's selection changes, update the tab view. + [[_segmentControl cell] addObserver:self + forKeyPath:@"selectedSegment" + options:0 + context:nil]; + // When the segment control's superview changes, recalculate the spacer + // segment widths. + [[_segmentControl superview] addObserver:self + forKeyPath:@"frame" + options:0 + context:nil]; [self updateSegmentControl]; - } /** @@ -126,8 +132,10 @@ [self debuggerConnected]; else [self debuggerDisconnected]; - } else if (object == self.segmentControl.cell) { - [self.tabView selectTabViewItemAtIndex:self.segmentControl.selectedSegment - 1]; + } else if (object == _segmentControl.cell) { + [_tabView selectTabViewItemAtIndex:_segmentControl.selectedSegment - 1]; + } else if (object == _segmentControl.superview) { + [self updateSegmentControl]; } else { [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } -- 2.22.5