tableview索引添加一个显示点击或滑动到哪个字母的控件

来源:互联网 发布:mac如何用阿里旺旺 编辑:程序博客网 时间:2024/04/30 21:50
-(NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index

{

  

//    

    //改变索引的颜色

    cnAirportTabView.sectionIndexColor = [UIColor blueColor];

    //改变索引选中的背景颜色

    cnAirportTabView.sectionIndexTrackingBackgroundColor = [UIColor grayColor];

    

 

    NSInteger count = 0;

    NSLog(@"%@-%d",title,index);

    

    xianshiLable =[[UILabel alloc]initWithFrame:CGRectMake(1001003030)];

    

    xianshiLable.textColor =[UIColor blackColor];

    xianshiLable.tag =999;

    xianshiLable.backgroundColor =[UIColor redColor];

    xianshiLable.textAlignment =NSTextAlignmentCenter;

    xianshiLable.text =title;

    [self.view addSubview:xianshiLable];

    if (tableView == cnAirportTabView) {

        NSLog(@"titleArraytitleArray:%@",titleArray);

        

        for(NSString *character in titleArray){

              NSLog(@"character:%@",character);

             NSLog(@"titleArray:%@",titleArray);

             NSLog(@"title:%@",title);

            if([character isEqualToString:title]){

            

                return count;

                

            }

            count ++;

        }

        

        

    } else if (tableView == searchResultTableView) {

        for(NSString *character in searchTitles){

        if([character isEqualToString:title]){

       

            return count;

        }

        count ++;

    }

    }

    

    

    return 0;

    

    

}

0 0
原创粉丝点击