Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear and Redraw with Cappuccino (Objective-J)

basically I have this

@implementation MyView : CPView
{
  CPArray MyPanelArray;
}

// Populate the MyPanelArray and position each panel
- (void)initMyView
{
  ...
}

MyPanels are pretty much wrappers for images. When everything is initialized it draws just fine. Then I have a slider to manipulate the position of the images and the only way I know how to redraw everything is to overwrite the MyView with a new instance and in the main contentView do something like

// Has the correct effect, but feels wrong
- (void)sliderAction:(id)sender
{
    var myNewView = [MyView initWithPositionValue:[sender value]];
    [_contentView replaceSubview:_myView with:myNewView];
    _myView = myNewView;
}

It works all right, but I doubt thats the "right way".

*I know I can use a CPCollectionView for a basic setup, but its not going to work for what I'm trying to accomplish.

Thanks in advance.

like image 995
Felix Avatar asked Dec 12 '25 04:12

Felix


1 Answers

By "redraw" do you mean actually doing a drawRect: or just moving/resizing the image views? If it's the latter then you can just call setFrame: on _myView.

like image 200
Francisco Ryan Tolmasky I Avatar answered Dec 15 '25 16:12

Francisco Ryan Tolmasky I