iOS implementation table (non-TableView)

Source: Internet
Author: User

Whdeform

IOS Forms项目地址:https://github.com/whde/WhdeForm

‘WhdeForm‘‘~> 1.0.0‘
    • Added a Reusable mechanism
    • Added a horizontal ( Section ) header
    • Added a vertical ( Column ) Table header
    • Added upper left corner ( TopLeftHeader ) Total header
    • By FDateSource going to create individual elements, likeTableView
    • Added aFIndexPath,{section, column}
    • Table header Add Click event
    • Added a grid

Use
#import "ViewController.h" #import "FormScrollView.h"  @interface viewcontroller () <fdelegate, fdatasource> {    Nsarray*_data;}@end @implementation viewcontroller - (void) Viewdidload {[SuperViewdidload]; Self. Edgesforextendedlayout= Uirectedgenone; Self. View. Autoresizingmask= Uiviewautoresizingnone; Formscrollview *table = [[Formscrollview alloc] Initwithframe:cgrectmake (0,0, Self. View. Frame. Size. Width, Self. View. Frame. Size. Height- -)]; Table. Contentinset= Uiedgeinsetsmake (0,0,0,0); Table. Fdelegate= Self; Table. Fdatasource= Self; [ Self. ViewAddsubview:table]; _data = [Nsarrayarraywithcontentsoffile:[[NSBundleMainbundle] pathforresource:@"Datas"oftype:@"Plist"]]; [Table Reloaddata];} -(Ftopleftheaderview *) Topleftheadviewforform: (Formscrollview *) Formscrollview {Ftopleftheaderview *view = [FormScro Llview Dequeuereusabletopleftview];if(View = =NULL{view = [[Ftopleftheaderview alloc] initwithsectiontitle:@"Number of rows"columntitle:@"Number of columns"]; }returnView;} - (Nsinteger) Numberofsection: (Formscrollview *) Formscrollview {return_data. Count;} - (Nsinteger) Numberofcolumn: (Formscrollview *) Formscrollview {return  -;} - (CGFloat) Heightforsection: (Formscrollview *) Formscrollview {return  -;} - (CGFloat) Widthforcolumn: (Formscrollview *) Formscrollview {return  the;} -(Formsectionheaderview *) Form: (Formscrollview *) Formscrollview sectionheaderatsection: (Nsinteger) Section {Formsectionheaderview *header = [Formscrollview dequeuereusablesectionwithidentifier:@"section"];if(Header = =NULL) {Header = [[Formsectionheaderview alloc] initwithidentifier:@"section"]; } [Header settitle:[NSStringstringwithformat:@"%ld Line", (Long) section] Forstate:uicontrolstatenormal];/*[header Setbackgroundcolor:[uicolor redcolor]];*/[Header settitlecolor:[UicolorBluecolor] Forstate:uicontrolstatenormal];returnHeader;} -(Formcolumnheaderview *) Form: (Formscrollview *) Formscrollview Columnheaderatcolumn: (Nsinteger) column {Formcolumnheaderview *header = [Formscrollview dequeuereusablecolumnwithidentifier:@"Column"];if(Header = =NULL) {Header = [[Formcolumnheaderview alloc] initwithidentifier:@"Column"]; } [Header settitle:[NSStringstringwithformat:@"%ld column", (Long) column] [forstate:uicontrolstatenormal];/*[header Setbackgroundcolor:[uicolor greencolor]];*/[Header settitlecolor:[UicolorBluecolor] Forstate:uicontrolstatenormal];returnHeader;}  -(Formcell *) Form: (Formscrollview *) Formscrollview Cellforcolumnatindexpath: (Findexpath *) Indexpath {FormCell *cell = [Formscrollview dequeuereusablecellwithidentifier:@"Cell"];NSLog(@"%@", cell);if(Cell = =NULL) {cell = [[Formcell alloc] initwithidentifier:@"Cell"];Static intI=0; i++;NSLog(@"%d--%ld", I, (Long) Indexpath. section); }nsdictionary*dic = [_data objectatindex:indexpath. section]; [Cell settitle:dic[@"Name"] Forstate:uicontrolstatenormal]; [Cell settitlecolor:[UicolorBluecolor] Forstate:uicontrolstatenormal];/*[cell Setbackgroundcolor:[uicolor yellowcolor]];*/    returnCell;} - (void) Form: (Formscrollview *) Formscrollview Didselectsectionatindex: (Nsinteger) Section {NSLog(@"Click section at Index:%ld", (Long) (section);} - (void) Form: (Formscrollview *) Formscrollview Didselectcolumnatindex: (Nsinteger) Column {NSLog(@"Click Cloumn at Index:%ld", (Long) column);} - (void) Form: (Formscrollview *) Formscrollview Didselectcellatindexpath: (Findexpath *) Indexpath {NSLog(@"Click Cell at Indexpath:%ld,%ld", (Long) Indexpath. section, (Long) Indexpath. Column);} - (void) Didreceivememorywarning {[SuperDidreceivememorywarning];}@end

iOS implementation table (non-TableView)

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.