Hides the UITableView scroll bar and modifies the color of the scrollbar, UITableView scrolls to the specified line section

Source: Internet
Author: User

Hide

Self.tableView.showsVerticalScrollIndicator = NO;

Modify ColorSelf.tableview.indicatorstyle=uiscrollviewindicatorstylewhite;UITableView Scroll to the specified line section

Nsindexpath *indexpath = [Nsindexpathindexpathforrow: 0 insection: 2];

CGRect frame = [tableviewRectforsection:indexpath. Section];

[TableView setcontentoffset: Cgpointmake(0, Frame.origin. Y) animated:YES ];

uitableview--Click a line to move to the specified location Blog Category:
    • Ios

When you select a row and want to tableview auto-scroll so that the selected row is always on table top, middle, or bottom, use one of the following methods:

[TableView scrolltorowatindexpath: Indexpath atscrollposition: Uitableviewscrollpositionbottom Animated :YES];

[TableView Scrolltonearestselectedrowatscrollposition:uitableviewscrollpositionbottom Animated:yes];

H file: Java code
    1. @interface Gkviewcontroller:uiviewcontroller <uitableviewdatasource,uitableviewdelegate>{
    2. BOOL bcheck[50];
    3. }
M File: Java code
  1. -(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) Section
  2. {
  3. return 50;
  4. }
  5. -(CGFloat) TableView: (UITableView *) TableView Heightforrowatindexpath: (Nsindexpath *) Indexpath
  6. {
  7. if (Bcheck[indexpath.row]) {
  8. return 100;
  9. }else{
  10. return 50;
  11. }
  12. return 50;
  13. }
  14. -(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath
  15. {
  16. static NSString *cellidentifier = @"Cell";
  17. UITableViewCell *cell = [TableView dequeuereusablecellwithidentifier:cellidentifier];
  18. if (cell = = nil)
  19. {
  20. cell= [[UITableViewCell Alloc]initwithstyle:uitableviewcellstyledefault
  21. Reuseidentifier:cellidentifier];
  22. Cell.accessorytype=uitableviewcellaccessorydisclosureindicator;
  23. }
  24. Cell.textlabel.text=[nsstring stringwithformat:@"%@%i", @"topic", Indexpath.row];
  25. return cell;
  26. }
  27. -(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) Indexpath
  28. {
  29. [Self initcheck];
  30. Bcheck[indexpath.row] = YES;
  31. [TableView Reloaddata];
  32. Bcheck[indexpath.row] = NO;
  33. [TableView Scrolltorowatindexpath:indexpath Atscrollposition:uitableviewscrollpositionbottom Animated:YES];
  34. [TableView Scrolltonearestselectedrowatscrollposition:uitableviewscrollpositionbottom Animated:yes];
  35. }

Hides the UITableView scroll bar and modifies the color of the scrollbar, UITableView scrolls to the specified line section

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.