Recently, the company project added a demand, and then to have the management of the delivery address, there is a single box settings, I wrote last night was written out very late, and I would like to share it today, but also the process of my own accumulation, of course, I gave today is a demo example, I can not move my project. The following will not say nonsense, directly on the code.
I am now writing a simple demo, as the following may be added to the difficult bar, and then I will update.
#import "ViewController.h"
#define ROWCOUNT 5
@interface Viewcontroller () <UITableViewDelegate,UITableViewDataSource>
@property (Nonatomic,strong) Nsmutablearray *allbuttonarray;
@end
@implementation Viewcontroller
-(void) Viewdidload {
[Super Viewdidload];
Self.allbuttonarray = [[Nsmutablearray alloc] init];
UITableView *tabview = [[UITableView alloc] InitWithFrame:self.view.frame Style:uitableviewstyleplain];
Tabview.delegate =self;
Tabview.datasource =self;
[Self.view Addsubview:tabview];
}
-(Nsinteger) Numberofsectionsintableview: (UITableView *) TableView
{
return 1;
}
-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) Section
{
return rowCount;
}
-(UITableViewCell *) TableView: (UITableView *) View Cellforrowatindexpath: (Nsindexpath *) Indexpath
{
static NSString *identifier = @ "identifier";
UITableViewCell *cell = (uitableviewcell*) [View Dequeuereusablecellwithidentifier:identifier];
if (Cell==nil) {
cell = [[UITableViewCell alloc] Initwithstyle:uitableviewcellstyledefault reuseidentifier:identifier];
Cell.selectionstyle = Uitableviewcellselectionstylenone;
Cell.textLabel.text = @ "AAA";
UIButton *button = [UIButton buttonwithtype:uibuttontypecustom];
Button.tag = 1000+indexpath.row;
[Button setimage:[uiimage imagenamed:@ "Unselect"] forstate:uicontrolstatenormal];
[Button settitle:@ "title" Forstate:uicontrolstatenormal];
Button.frame = CGRectMake (0, 0, 200, 60);
[Button addtarget:self action: @selector (ButtonClick:) forcontrolevents:uicontroleventtouchupinside];
[Cell Addsubview:button];
[_allbuttonarray Addobject:button];
}
return cell;
}
-(void) ButtonClick: (UIButton *) button
{
NSLog (@ "click-----------");
[Button setimage:[uiimage imagenamed:@ "selected"] forstate:uicontrolstatenormal];
[Button settitle:@ "Afterclick" forstate:uicontrolstatenormal];
for (int i=0; i<rowcount; i++) {
Nsinteger tag = 1000+i;
if (Tag!=button.tag) {
UIButton *unselectedbutton = (UIButton *) [Self.view Viewwithtag:tag];
[Unselectedbutton setimage:[uiimage imagenamed:@ "unselect"] forstate:uicontrolstatenormal];
// }
// }
for (int i=0; I<[_allbuttonarray count]; i++) {
UIButton *cellbutton = (UIButton *) _allbuttonarray[i];
if (Cellbutton!=button) {
[Cellbutton setimage:[uiimage imagenamed:@ "unselect"] forstate:uicontrolstatenormal];
}
}
}
-(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) Indexpath
{
NSLog (@ ".....");
}
-(void) didreceivememorywarning {
[Super didreceivememorywarning];
Dispose of any resources the can be recreated.
}
@end
iOS Fake delivery address management