IOS UITableView Fast Scrolling (indexed way implementation)

Source: Internet
Author: User

Reference: http://my.oschina.net/joanfen/blog/204503

Idea: UITableView need to slide multiple contacts when too much data is loaded at once. To quickly slide through an index, 20 empty points are loaded in the index. When the user slides to the right, the index box shows the rowindex that points to the uitableview that they want to use when hitting the index point for fast scrolling. This method has a flaw: the scroll bar is obscured during normal sliding.

Main code:

Get data-(void) gettabledata{Dispatch_async (dispatch_get_global_queue (dispatch_queue_priority_default, 0), ^{ Dispatch_async (Dispatch_get_main_queue (), ^{//Get database data Self.listarray = [[Reportlogic Sharedinstanc            E] getproductbycategory];            if ([self.listarray count] = = 0) {[globalapplication alert:@ "hint": @ "no data"];                }else{//Index directory, 20 empty points nsmutablearray *starray = [[Nsmutablearray alloc] init];                Self.sectiontitles = Starray;                [Starray release];                    for (int i=0;i<20;i++) {NSString *index = @ "";                [Self.sectiontitles Insertobject:index atindex:i];        }}//Data refresh [Self.fmtableview Reloaddata];    }); });} #pragma mark index//partition number-(Nsinteger) Numberofsectionsintableview: (UITableView *) tableview{return 1;} Index directory-(Nsarray *) sectionindextitlesfortablEview: (UITableView *) tableview{return self.sectiontitles;} Swipe to click on the catalogue-(Nsinteger) TableView: (UITableView *) TableView sectionforsectionindextitle: (NSString *) title Atindex: (    Nsinteger) index{//Fixed index focus is UITableView rowindex, tail and middle value if (index = = 0) {index = 1;    }else if (index = = self.sectiontitles.count-1) {index = self.listarray.count-1;    }else index = round (INDEX*SELF.LISTARRAY.COUNT/20); [Self.fmtableview scrolltorowatindexpath:[nsindexpath Indexpathforrow:index insection:0] AtScrollPosition:    Uitableviewscrollpositionbottom Animated:yes];  return index;}

Effect:


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.