沃梦达 / IT编程 / 移动开发 / 正文

iOS中tableview 两级cell的展开与收回的示例代码

本篇文章主要介绍了iOS中tableview 两级cell的展开与收回的示例代码,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

由于文章内容的限制,我们接着在上文的内容展开,上文的方案中还是存在一个问题的,如果我们展开了多个section,并且展开的section不在屏幕上面,当我们滑动的时候,section再次回到屏幕的时候,展开的图标就不是再往下了,如下图所示:


//数据重新加载的时候,展开图标的重新设置 
f (Title [(int)section].ExplandFlag) { 
headerView.ExplandButton.SetImage (UIImage.FromBundle ("arrowD"), UIControlState.Normal); 
 else { 
headerView.ExplandButton.SetImage (UIImage.FromBundle ("arrow"), UIControlState.Normal); 

当你会发现,程序还有一些漏洞,当你在收回一些section(这些个section是从复用池操作过来的),图标缺收回不过来。如下图所示:


//标志位改变 
Title[(int)section].ExplandFlag=false; 
//图标的复位 
UIButton explandButton=(UIButton)sender; 
explandButton.SetImage (UIImage.FromBundle ("arrow"), UIControlState.Normal); 
myTabViSource.ReturnRotate(explandButton); 
//数据插入 
int length=Title[(int)section].SecondTitle.Count; 
NSIndexPath[] arrayIndexPath=new NSIndexPath[length]; 
for(int i=0;i<length;i++) 
{ 
  arrayIndexPath[i]=NSIndexPath.FromRowSection((nint)i,section); 
} 
tableview.DeleteRows(arrayIndexPath,UITableViewRowAnimation.Automatic); 

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程学习网。

本文标题为:iOS中tableview 两级cell的展开与收回的示例代码