2

I have the following code attached to an NSButton

- (IBAction) onTest: (id) sender
{
    NSLog(@"OnTest");
    [overlayView setFrame: scrollView.frame];
    [scrollView.superview addSubview: overlayView];
}

My nib is setup as the following picture:

nib setup

The scrollView outlet is attached to the NSScrollView that encloses a NSTableView and the overlayView is attached to a NSView that has a green background.

On the click of a button, I receive the OnTest log message in xcode, but the green view is not visible, however if I switch focus from the applications window to say XCode, then back to the window, the green overlay is now visible.

I've tried using [scrollView.superView setNeedsDisplay: YES], but that still does not cause the green view to be displayed.

Any suggestions as to that I'm doing wrong?

Kyle
  • 17,317
  • 32
  • 140
  • 246
  • Did you try calling the setNeedsDisplay: of the overlay view instead? Also who is scrollView.superview? – Alex Salom Jul 03 '14 at 12:05
  • Yes, I have tried `setNeedsDisplay:` on both views. `scrollView.superView` would be the main view of the window. "The view instances enclosed within a view are called subviews. The parent view that encloses a view is referred to as its superview" (https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CocoaViewsGuide/WorkingWithAViewHierarchy/WorkingWithAViewHierarchy.html) – Kyle Jul 03 '14 at 12:45
  • Did you turn on layers for the views? Overlapping sibling views that don't have layers don't work. See http://stackoverflow.com/questions/466297/is-there-a-proper-way-to-handle-overlapping-nsview-siblings – tsnorri Jul 08 '14 at 18:23

0 Answers0