需要有关在 iPhone SDK 中刷新 UIView 的帮助
我有一个简单的向下钻取导航应用程序。在详细视图上,我正在绘制一些 20x20 大小的 UIImage,具体取决于导航项中选择的行。当选择一行时,这些图像将作为详细视图上的子视图绘制。现在,当我进入“详细视图”时,我设置了几个按钮,按下这些按钮时,将重新排列小图像。为此,我需要清除以前的图像并在视图中的不同位置重新绘制它们。我有一个类似的方法: [MyView changeImagePositionwithPosnumber:"通过按钮选择的数字"] 当按下按钮时我无法通过此方法,因为它会覆盖现有图像。 如何刷新视图以传递此方法?我需要为此实现绘制矩形吗? 我不太了解drawrect,也不知道如何实现它。 简而言之,当您离开详细视图时,无论导航控制器做什么,我都想做,这样我就可以刷新视图并在其上绘制新图像。 非常感谢对此的任何帮助。我还是个新手。
I have a simple drill down navigation app. On the detail view, I am drawing a few 20x20 sized UIImages, depending upon the row selected in the navigation items. These images are drawn as subviews over the detail view when a row is selected.Now when I get to the "detail view" I have set up a couple of buttons, which when pressed, will rearrange the small images. For this I need to clear the previous images and redraw them at different places in the view. I have a method like:
[MyView changeImagePositionwithPosnumber:"number selected by buttons"]
I cannot pass this method when the button is pressed since it draws over the existing images.
How do I refresh the view to pass this method ? Do I need to implement draw rect for this?
I do not quite understand drawrect and am not sure how to implement it.
In short whatever the navigation controller does when you go away from detail view, I want to do, so I can refresh my view and draw new images on it.
Any help on this is greatly appreciated. I am still a newbie.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这对我有用:
UIView *视图:
for(UIView *[查看子视图]中的子视图) {
[子视图removeFromSuperview];
}
谢谢
This worked for me:
UIView *view:
for(UIView *subview in [view subviews]) {
[subview removeFromSuperview];
}
Thanks