用卡布奇诺清除并重新绘制 (Objective-J)
基本上我有这个
@implementation MyView : CPView
{
CPArray MyPanelArray;
}
// Populate the MyPanelArray and position each panel
- (void)initMyView
{
...
}
MyPanels 几乎是图像的包装器。 当一切都初始化后,它就画得很好了。 然后我有一个滑块来操纵图像的位置,我知道如何重绘所有内容的唯一方法是用新实例覆盖 MyView 并在主 contentView 中执行类似的操作
// Has the correct effect, but feels wrong
- (void)sliderAction:(id)sender
{
var myNewView = [MyView initWithPositionValue:[sender value]];
[_contentView replaceSubview:_myView with:myNewView];
_myView = myNewView;
}
它工作正常,但我怀疑这就是“正确的方法”。
*我知道我可以使用 CPCollectionView 进行基本设置,但它无法完成我想要完成的任务。
提前致谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过“重绘”,您的意思是实际执行绘制矩形:还是只是移动/调整图像视图的大小? 如果是后者,那么您只需在 _myView 上调用 setFrame: 即可。
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.