The previous blog has introduced how to use the UITableView horizontal screen swipe, this blog with a click to enlarge the operation, is placed on the UITableViewCell cell, because the visual control too much, so hide, The method of use is also simple. Userinteractionenabled = False is fine.
1. Click the UIButton in the image to enlarge, first to write UIButton method
2. There are many ways to change the size of a control, a size after a change, a previous size
3. The default is the first check, like a radio, then define a tag, and then each click on the replacement tag, and then do the comparison is not the same tag
4. Then just refresh the UITableView
#import "ViewController.h" #import "FFTableViewCell.h" @interface ViewController () < Uitableviewdelegate,uitableviewdatasource> @property (strong,nonatomic) uitableview *mytableview;@ Property (strong,nonatomic) nsindexpath *selectedindexpath; @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 &NBSP;/&NBSP;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]; self.selectedindexpath = [nsindexpath indexpathforrow:0 insection:0]; // 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{&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&Nbsp; fftableviewcell *cell = [fftableviewcell cellwithtableview:tableview]; if ([Self.selectedindexpath isequal:indexpath]) { [cell zoomPtoto:YES]; }else{ [cell zoomptoto:no]; } return cell;} #pragma mark selected method- (void) TableView: (uitableview *) Tableview didselectrowatindexpath :(nsindexpath *) indexpath{ [tableview deselectrowatindexpath:indexpath animated:yes]; self.selectedindexpath = indexpath; [ Self.mytableview reloaddata];} - (void) Dealloc{ _mytableview = nil;} - (void) didreceivememorywarning { [super didreceivememorywarning]; // diSpose of any resources that can be recreated.} @end #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 = 20.0f; _monthBtn.clipsToBounds = YES; [_monthbtn settitle:@ "What to Do" forState:UIControlStateNormal]; _monthbtn.titlelabel.font = [uifont systemfontofsize:11.0f]; _monthbtn.userinteractionenabled &NBSP;=&NBSP;FALSE;&NBSP;&NBSP;&NBSP;&NBSP;}&NBSP;&NBSP;&NBSP;&NBSP;RETURN&NBSP;_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) { self.contentview.transform = cgaffinetransformmakerotation (m_pi / 2); [self.contentview addsubview:self.monthbtn]; } return self;} - (void) Zoomptoto: (BOOL) isbool{ _isbool = isbool; if (Isbool) { _monthbtn.layer.cornerradius = 30.0f; _monthbtn.frame = cgrectmake ((CGRectGetWidth ( Self.contentView.frame) -60)/2, (Cgrectgetheight (self.contentView.frame) -60)/2, 60,60); }else{ _monthbtn.layer.cornerradius = 20.0f; _monthbtn.frame = cgrectmake ((Cgrectgetwidth (self.contentView.frame) -40)/2, (Cgrectgetheight (self.contentView.frame)- /2, 40,40); }}- (void) layoutsubviews{ [super Layoutsubviews]; if (_isbool) { _monthBtn.layer.cornerRadius = 30.0f; _monthbtn.frame = cgrectmake ((Cgrectgetwidth (self.contentView.frame) -60)/2, ( Cgrectgetheight (self.contentView.frame) -60)/2, 60,60); }else{ _monthbtn.layer.cornerradius = 20.0f; _monthbtn.frame = cgrectmake (( Cgrectgetwidth (Self.contentView.frame)-40)/2, (Cgrectgetheight (self.contentView.frame) -40)/2, 40,40); }}- (void) SetSelected: (BOOL) selected animated: (bool) animated { [super setselected: selected animated:animated]; // configure the view for the selected state}- (void) Dealloc{ _monthbtn = nil;} @end
IOS UITableView Horizontal Swipe click UIButton Zoom In