Clear and redraw using cappuccino (Objective-J)

I basically have it

@implementation MyView : CPView
{
  CPArray MyPanelArray;
}

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

MyPanels are quite a few image wrappers. When everything is initialized, it is perfectly drawn. Then I have a slider to control the position of the images, and the only way I know how to redraw everything is to overwrite MyView with a new instance, and basically the contentView to 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;
}

Everything works correctly, but I doubt that this is the “right way”.

* I know that I can use CPCollectionView for a basic installation, but this will not work for what I'm trying to accomplish.

Thanks in advance.

+3
source share
1 answer

"" drawRect: / ? , setFrame: on _myView.

+5

Source: https://habr.com/ru/post/1708785/


All Articles