In the development of horizontal sliding we usually think of using uicollectionview, it is really useful, but sometimes the needs are not very clear and with Uicollectionview head need to customize no UITableView simple, zongzi see demand, according to the needs of the decision, But we have to have this skill.
@interface ViewController () <UITableViewDelegate,UITableViewDataSource> @property (Strong, nonatomic) uitableview *mytableview; @end @implementation viewcontroller- (UITableView *) Mytableview{ if (!_mytableview) { cgrect tableviewrect = cgrectmake (0, 0,100, cgrectgetwidth (self.view.frame)); _mytableview = [[uitableview alloc] initwithframe: Cgrectzero style:uitableviewstyleplain]; _ Mytableview.datasource = self; _mytableview.delegate = self; _mytableview.frame = tableviewrect ; _mytableview.separatorstyle = no; _mytableview.baCkgroundcolor = [uicolor graycolor]; _ Mytableview.transform = cgaffinetransformmakerotation (-m_pi / 2); _myTableView.showsVerticalScrollIndicator = NO; _mytableview.center = cgpointmake (Self.view.frame.size.width / 2, &NBSP;50); } return _mytableview;} - (void) viewdidload { [super viewdidload]; //AppDelegate Global Settings if (@available (ios 11.0, *)) { [[uiscrollview appearance] setcontentinsetadjustmentbehavior:uiscrollviewcontentinsetadjustmentnever]; } self.view.backGroundcolor = [uicolor purplecolor]; [self.view addsubview: self.mytableview]; // do any additional setup after Loading the view, typically from a nib.} - (CGFloat) TableView: (uitableview *) Tableview heightforrowatindexpath: (nsindexpath *) indexpath{ return 100;} -(Nsinteger) TableView: (uitableview *) Tableview numberofrowsinsection: (Nsinteger) section{ return 50;} - (uitableviewcell *) TableView: (uitableview *) Tableview cellforrowatindexpath: (NSIndexPath *) indexpath{ fftableviewcell *cell = [ Fftableviewcell cellwithtableview:tableview]; return cell;} #pragma mark selected method- (void) TableView: (uitableview *) Tableview didselectrowatindexpath :(Nsindexpath *) indexpath{ [tableview deselectrowatindexpath:indexpath Animated:yes];} #import "FFTableViewCell.h" @interface fftableviewcell () @property (strong,nonatomic) uibutton * MONTHBTN, @end @implementation fftableviewcellstatic nsstring *cellid = @ " Fftableviewcell ";- (uibutton *) monthbtn{ if (!_MONTHBTN) { _monthBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _monthBtn.backgroundColor = [UIColor redColor]; _monthBtn.layer.cornerRadius = 30.0f; _monthBtn.clipsToBounds = YES; [_monthbtn settitle:@ "What are you doing" &NBSP;FORSTATE:UICONTROLSTATENORMAL];&NBSP;&NBSP;&NBSP;&NBSP;} return _monthbtn;} - (void) awakefromnib { [super awakefromnib]; // Initialization code}+ (Instancetype) Cellwithtableview: (uitableview *) tableview{ FFTableViewCell *cell = [tableView dequeuereusablecellwithidentifier:cellid]; if (Cell == nil) { cell = [[fftableviewcell alloc]initwithstyle: uitableviewcellstyledefault reuseidentifier:cellid]; } Return cell;} - (Instancetype) Initwithstyle: (Uitableviewcellstyle) Style reuseidentifier: (NSString *) Reuseidentifier{ self = [super initwithstyle:style reuseidentifier: Reuseidentifier]; if (self) { &nBsp;self.contentview.transform = cgaffinetransformmakerotation (m_pi / 2); [self.contentview addsubview:self.monthbtn]; } return self;} - (void) layoutsubviews{ [super layoutsubviews]; _ Monthbtn.frame = cgrectmake ((Cgrectgetwidth (self.contentView.frame) -60)/2, (Cgrectgetheight ( Self.contentView.frame) ( -60)/2, 60,60);} - (void) setselected: (BOOL) selected animated: (BOOL) Animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state}- (void) dealloc{ _monthbtn = nil;} @end
To solve the problem more than one way, to think more about other solutions, so as to better grasp each knowledge point, perhaps better, perhaps is the face of the question waiting.
Horizontal swipe of IOS UITableView