ios - How to create group of buttons when i clicked one button (add button) in objective C? -


i new ios development. creating 1 application contains 1 button, acts add button. if click button, want create set of 3 buttons. when click add button, every time these buttons want create next previous buttons. need idea or sample code that. code:

-(void) addbtnact {      [self.view addsubview:sizedropdownbtn];     deletebtn.hidden=yes;     [sizedropdownbtn addsubview:sizedropdownbtnlbl];     [self.view addsubview:weightdropdownbtn];     [weightdropdownbtn addsubview:weightdropdownbtnlbl];     [self.view addsubview:quantitytxtfld];     [quantitytxtfld addsubview:quantitylbl];     sizedropdownbtn.frame = cgrectmake(10, 190, 86, 40);     weightdropdownbtn.frame = cgrectmake(110, 190, 86, 40);     quantitytxtfld.frame = cgrectmake(220, 190, 86, 40);     quantitylbl.frame = cgrectmake(10, 12, 100, 15);     sizedropdownbtnlbl.frame = cgrectmake(20, 12, 100, 15);     weightdropdownbtnlbl.frame = cgrectmake(10,12, 100, 15); 

sorry bad english. thank you.

hi plese try following code:

int x=10; int y=10;  for(int i=0;i<3;i++) {    cgrect frame = cgrectmake(10, y, 280, 40);         uibutton *button = [uibutton buttonwithtype:uibuttontypecustom];         button.frame = frame;         button.tag=i;         [button settitle:(nsstring *)@"new button" forstate:(uicontrolstate)uicontrolstatenormal];         [button addtarget:self action:@selector(buttontapped:) forcontrolevents:uicontroleventtouchupinside];         [button setbackgroundimage:[uiimage imagenamed:@"temp.png"] forstate:uicontrolstatenormal];         [self.view addsubview:button]; y+=45; } 

hope code you.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -