【发布时间】:2012-02-06 10:18:50
【问题描述】:
我的主 UIScrollView 有很多关闭按钮,我这样创建:
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom]
每个按钮都有一个图像:
UIImage *fileImage = [UIImage imageNamed:@"sun.png"];
[myButton setBackgroundImage:fileImage forState:UIControlStateNormal];
按钮数量可能超过 500 个。所以我需要从 UIscrollView 中删除带有图像的不可见按钮以节省内存?
我相信在这种方法中,我需要计算 UIscrollview 何时停止滚动并且例如 20 个图像不可见,然后我需要删除它们并减少滚动内容偏移量。
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
float bottomEdge = scrollView.contentOffset.y + scrollView.frame.size.height;
}
也许有人可以给我一些建议。甚至有一个很好的书签教程。
【问题讨论】:
-
嗨,我有一年多的经验。永远不要释放按钮,它会给你带来糟糕的过度或崩溃。你只需要从滚动条中删除。您没有任何其他按钮选项...
-
我没有遇到发布。我只是想删除它们,但就我而言,这并不容易,因为我从网络上获取了这些按钮的图像。
标签: objective-c ios uiscrollview uibutton uiimage