• 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
probablem with NSView redisplay.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

probablem with NSView redisplay.


  • Subject: probablem with NSView redisplay.
  • From: Mac First <email@hidden>
  • Date: Thu, 2 Jul 2009 15:15:47 -0700

I have an NSWindowController driving a window, with a view, with subviews. One of the subviews is an NSView *imageParentView. This view's only purpose is to provide a frame, a "bounding box" inside which its subview will be held. It's one and only subview is NSImageView *imageView.

The purpose is for imageView -- which displays a 1700x800 image -- to move around inside of imageParentView, which limits things to a "peephole" view of a 100x100 area. Thus, I create a flip-book style animation from a larger image. Elsewhere in the main view, I have a slider and some controls to move "next/prev", etc.

Below is the code I call after my animationFrame variable has been updated (say, by the NEXT or PREV buttons.) My problem is: SOME OF THE TIMES, it all works, and works perfectly. But SOMETIMES, I'll run the app, and I'll see the 1st image but, after advancing the counter, subsequent images do not redraw. This works/does-not-work dichotomy does not require code or xib changes -- sometimes I just give up on it for a day, come back the next day, and everything works fine.

My animationFrameLabel -- the thing that tells me which "frame" (column/row of the bigger image) should be displaying -- updates, so I know all the code is happening.

On the times when the updates are not visible, even covering and uncovering the window (hoping to force a redraw) does not help.

...But sometimes the program just works flawlessly.

Am I missing some key call?  What's going on?

Thanks!

	--- Code ---

 - (void)displayAnimationFrame {
    int xx = (animationFrame % animationColumns);
    int yy = (animationFrame / animationColumns);

[animationFrameLabel setStringValue:[NSString stringWithFormat:@"{ %d, %d }", xx, yy]];

    [self adjustAnimationSlider];

    // Move imageView within imageParentView
    NSRect iParentViewFrame = imageParentView.frame;
    CGFloat xStart = iParentViewFrame.size.width  * xx;
    CGFloat yStart = iParentViewFrame.size.height * yy;

NSRect imageViewBounds = imageView.bounds;
imageViewBounds.origin.x = xStart;
imageViewBounds.origin.y = yStart;
NSLog(@"origin: %0.1f,%0.1f", imageViewBounds.origin.x, imageViewBounds.origin.y);
NSLog(@"..size: %0.1fx%0.1f", imageViewBounds.size.width, imageViewBounds.size.height);
[imageView setBounds:imageViewBounds];


    [imageView setNeedsDisplay];
    [imageParentView setNeedsDisplay:YES];
 }


--- Log output ---

2009-07-02 15:09:49.756 app[35064:10b] origin: 100.0,0.0
2009-07-02 15:09:49.757 app[35064:10b] ..size: 1699.8x799.9
2009-07-02 15:09:50.267 app[35064:10b] origin: 200.0,0.0
2009-07-02 15:09:50.268 app[35064:10b] ..size: 1699.8x799.9
2009-07-02 15:09:50.533 app[35064:10b] origin: 300.0,0.0
2009-07-02 15:09:50.533 app[35064:10b] ..size: 1699.8x799.9
2009-07-02 15:09:50.715 app[35064:10b] origin: 400.0,0.0
2009-07-02 15:09:50.715 app[35064:10b] ..size: 1699.8x799.9
2009-07-02 15:09:50.907 app[35064:10b] origin: 500.0,0.0
2009-07-02 15:09:50.907 app[35064:10b] ..size: 1699.8x799.9
2009-07-02 15:09:51.093 app[35064:10b] origin: 600.0,0.0
2009-07-02 15:09:51.093 app[35064:10b] ..size: 1699.8x799.9

_______________________________________________

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


  • Prev by Date: documenting bindings (was: Re: Dynamically loading a part of a Window in Cocoa)
  • Next by Date: Changing content of object inside NSMutableArray
  • Previous by thread: Re: screen lock events?
  • Next by thread: Changing content of object inside NSMutableArray
  • Index(es):
    • Date
    • Thread