iOS UITableView~members(常用成员方法)

来源:互联网 发布:excel数据透视 编辑:程序博客网 时间:2024/05/21 08:58

//联系人:石虎  QQ: 1224614774昵称:嗡嘛呢叭咪哄

一、UITableView常用成员方法


    //通过indexpath获取指定行的uitableviewcell

    [_table cellForRowAtIndexPath:indexPath];


    //删除某行并带上动画

    [_table deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];


    //删除某个section并带上动画

    [_table deleteSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationMiddle];


    //取消被选中的某行

    [_table deselectRowAtIndexPath:indexPath animated:YES];


    //返回某个sectionheader自定义view

    [_table headerViewForSection:indexPath.row];


    //返回某个sectionfooter自定义view

    [_table footerViewForSection:indexPath.row];


    //通过指定的cell获取cell所在的行数

    [_table indexPathForCell:cell];


    //通过在table的位置坐标返回该坐标所在的cell的行数

    [_table indexPathForRowAtPoint:CGPointMake(0,0)];


    //返回被选中的cell的行数

    [_table indexPathForSelectedRow];


    //返回table中一个范围区域的cell的行数

    [_table indexPathsForRowsInRect:CGRectMake(0,0,100,100)];


    //返回table视觉区域内的cell的行数

    [_table indexPathsForVisibleRows];


    //以动画方式在指定的位置插入cell

    [_table insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];


    //以动画方式在指定位置插入section

    [_table insertSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationRight];


    //返回指定位置的cellrect属性

    [_table rectForRowAtIndexPath:indexPath];


    //重新加载table,重新执行所有回调方法

    [_table reloadData];


    //指定重新加载table的某些行,并以动画方式

    [_table reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationTop];


    //重新加载索引栏

    [_table reloadSectionIndexTitles];


    //指定重新加载tablesection,并以动画方式

    [_table reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade];


    //滑动table到顶部

    [_table scrollsToTop];


    //带动画方式滑动table到指定区间

    [_table scrollRectToVisible:CGRectMake(0,0,100,100) animated:YES];


    //带动画方式滑动table到指定位置附近

    [_table scrollToNearestSelectedRowAtScrollPosition:UITableViewScrollPositionBottom animated:YES];


    //以动画方式从table的哪个指定位置滑动到指定的行

    [_table scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];


    //返回table可视区域内所有的cell

    [_table visibleCells];


    //beginupdatesendupdates要成对出现,对于同时操作多个insertdeleteselection的动画操作需要把它们放在beginupdatesendupdates中间执行,这样可以把多个动画合成一个动画来处理,实现原子性,降低出错的机率
      [_table beginUpdates];

      [_table endUpdates];

   

谢谢!!!

原创粉丝点击