zoukankan      html  css  js  c++  java
  • 隐藏UITableView的滚动条以及修改滚动条的颜色,UITableView 滚动到指定行 section

       
    //隐藏

    self.tableView.showsVerticalScrollIndicator = NO;

    //修改颜色
    self.tableView.indicatorStyle=UIScrollViewIndicatorStyleWhite;
     
     
     

    UITableView 滚动到指定行 section

        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:2];

        CGRect frame = [tableview rectForSection:indexPath.section];

        [tableview setContentOffset:CGPointMake(0, frame.origin.y) animated:YES];

     
     
     
     

     

     选中某一行后想要tableView自动滚动使得选中行始终处于table的top、middle或者bottom,使用以下方法中的一个就可以实现:

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

    //    [tableView scrollToNearestSelectedRowAtScrollPosition:UITableViewScrollPositionBottom animated:YES];

    h文件:
    Java代码  收藏代码
    1. @interface GKViewController : UIViewController <UITableViewDataSource,UITableViewDelegate>{  
    2.     BOOL bCheck[50];  
    3. }  
    m文件:
    Java代码  收藏代码
    1. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section  
    2. {  
    3.     return 50;  
    4. }  
    5.   
    6. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath  
    7. {  
    8.     if (bCheck[indexPath.row]) {  
    9.           
    10.         return 100;  
    11.     }else{  
    12.           
    13.         return 50;  
    14.     }  
    15.       
    16. //    return 50;  
    17. }  
    18.   
    19. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath  
    20. {  
    21.     static NSString *CellIdentifier = @"Cell";  
    22.     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];  
    23.     if(cell == nil)  
    24.     {  
    25.         cell= [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault  
    26.                                     reuseIdentifier:CellIdentifier];  
    27.         cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;  
    28.     }  
    29.       
    30.     cell.textLabel.text=[NSString stringWithFormat:@"%@%i",@"话题",indexPath.row];  
    31.       
    32.     return cell;  
    33. }  
    34.   
    35. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath  
    36. {  
    37.     [self initCheck];  
    38.       
    39.       
    40.     bCheck[indexPath.row] = YES;  
    41.       
    42.     [tableView reloadData];  
    43.     bCheck[indexPath.row] = NO;  
    44.       
    45. [tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];  
    46. //    [tableView scrollToNearestSelectedRowAtScrollPosition:UITableViewScrollPositionBottom animated:YES];  
  • 相关阅读:
    jdbc连接数据库(mysql,sqlserver,oracle)
    简单粗暴将sqlserver表以及数据迁移到oracle
    LXD 2.0 系列(五):镜像管理
    LXD 2.0 系列(十二):调试,及给 LXD 做贡献
    LXD 2.0 系列(七):LXD 中的 Docker
    LXD 2.0 系列(四):资源控制
    LXD 2.0 系列(三):你的第一个 LXD 容器
    LXD 2.0 系列(二):安装与配置
    LXD 2.0 系列(一):LXD 入门
    Debian-linux 网卡配置
  • 原文地址:https://www.cnblogs.com/allanliu/p/4215624.html
Copyright © 2011-2022 走看看