NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet]
for ( NSIndexPath *indexPath in indexPathsForVisibleRows ) {
[indexSet addIndex:indexPath.section]
}
NSLog(@"indexSet %@",indexSet)
// indexSet <NSMutableIndexSet: 0x11a5c190>[number of indexes: 5 (in 1 ranges
思路就是:找出父节点的所有子节点的checked的属性设置成与父节点一致即可我是利用jquery实现,看看是否符合你的要求
<script src="../lib/jquery.js" type="text/javascript"></script>
<script src="../jquery.treeview.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$("#tree").treeview()
$("input[name='ids']").click(function(){
var checkedValue = this.checked
$(this).parent("li").find("input[name='ids']").attr("checked",checkedValue)
})
})
</script>
<ul id='tree'>
<li>
<input type='checkbox' name='ids' id="test"/>
<span class='folder'>test1</span>
<ul>
<li>
<input type='checkbox' name='ids' />
<span class='folder'>test11</span>
</li>
</ul>
<ul>
<li>
<input type='checkbox' name='ids' />
<span class='folder'>test12</span>
<ul>
<li>
<input type='checkbox' name='ids' />
<span class='folder'>test121</span>
</li>
</ul>
</li>
</ul>
</li>
</ul>