iOS Fake delivery address management

Source: Internet
Author: User

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

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.