我有UIScrollView有很多行(〜100),我實現了dequeueReusableRow方法來快速分配和添加我的子視圖(行)。一切工作正常,但如果我滾動速度非常快,減速一些視圖不只是以後添加到scrollView的時間。滾動時快速添加子視圖(行)到UIScrollView
- (UIView *)dequeueReusableRow
{
UIView *view = [reusableRows anyObject];
if(view)
{
[[view retain] autorelease];
[reusableRows removeObject:view];
}else{
view = [[UIView alloc] init....
}
return view;
}
- (void)addVisibleRows
{
UIView *row = [self dequeueReusableRow];
row.frame = ....
[scrollView addSubview:row]
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
[self addVisibleRows];
[self removeInvisibleRows];
}
請,不建議我用的UITableView因爲手風琴的結構如下:
section
- section
-- section
--- row
- section
section
- row
我建議你使用的UITableView。 http://stackoverflow.com/questions/1944428/how-to-implement-an-accordion-view-for-an-iphone-sdk-app – jrturton