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 a
FIndexPath,{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)