NSImageView resize

Discussion in 'Mac Programming' started by rocotilos, Oct 14, 2012.

  1. rocotilos macrumors newbie

    Joined:
    Nov 8, 2010
    #1
    Hi.

    I'm just playing around with OSX app dev. I'm totally noob.
    I thought it is straight forward like iOS app dev. But after a few days
    of going at this, it seems it is not that easy.

    Here's what I'm trying to do. I have a NSWindow. In it I put an Image Well (wth with the naming? lol)
    Well, it is an NSImageView (no pun intended).

    So I just want the NSImageView frame to resize following the NSWindow size. It's that simple.

    Here's what I did that is NOT working:

    NSImageView as imageView.

    write the delegate method of NSWindow windowDidResize and just resize the framesize
    of imageView in it.
    Code:
    - (void)windowDidResize:(NSNotification *)notification {
        
       // NSLog(@"resized");
        
        NSRect zWindowRect = [[self window]frame];
        NSRect zContentRect = [[self window]contentRectForFrameRect:zWindowRect];
    
        [self.imageView setFrameSize:NSMakeSize(zContentRect.size.width,
                                                zContentRect.size.height)];
        
        [self.imageView setNeedsDisplay:YES];
        
        
    }
    
    This delegate is called (tested with that NSLog).
    However the NSImageView just stays there with the original size.
    I checked the IBOutlet connection is ok.

    What gives? Why won't the NSImageView resize?
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    What makes you think the view is not resizing? Maybe it is but it's not set to scale it's content...
     
  3. rocotilos thread starter macrumors newbie

    Joined:
    Nov 8, 2010
    #3
    Scaling is set to Proportional so that was not the problem.

    I have found out the cause though - "Use Auto Layout" was checked for the NIB file.

    Unchecked that and everything works well now.
    Thanks for replying though. :)
     

Share This Page