iphone - Is it possible to move the uibutton to different positions without using tag values? -


here used tag values differentiate uibuttons. want move uibuttons different positions around table (like zynga poker)without using tag values? x , y positions has differ. example if write x+=100; y+=12; every time x , y positions incremented same value in round table x , y positions wont incremented same values.

with below code can move uibutton(or uiimageviews) positions using tag values code become more(means it'll occupy more memory).

i wanna distribute 35 image cards.

can provide me information regarding this?

code:

for(int i=1 ;i<35;i++) {     nslog(@"inside loop");     uibutton *btn_show=[uibutton buttonwithtype:uibuttontypecustom];     btn_show.frame=cgrectmake(190+(i/2), 20, 71, 96);     btn_show.tag=i;     [btn_show setimage:[uiimage imagenamed:@"back.png"] forstate:uicontrolstatenormal];     [self.view addsubview:btn_show];     [self fun_animations:btn_show];  }  -(void)fun_viewanimations {     [uiview beginanimations:nil context:null];     [uiview setanimationbeginsfromcurrentstate:yes];     [uiview setanimationduration:0.2];     [uiview setanimationcurve:uiviewanimationcurveeaseinout];  } -(void)fun_animations:(uibutton *)button {     [self fun_viewanimations];     if(button.tag==1)     {          [uiview setanimationdelay:1.0];          button.frame=cgrectmake(290,10, 71, 96);      }     if(button.tag==2)     {          [uiview setanimationdelay:1.2];          button.frame=cgrectmake(390,110, 71, 96);      }     .....     .....     [uiview commitanimations]; } 

you can use array index without setting tag button.here code

 - (void)viewdidload {      btnarray=[[nsmutablearray alloc] init];      for(int i=1 ;i<10;i++)     {         nslog(@"inside loop");         uibutton *btn_show=[uibutton buttonwithtype:uibuttontyperoundedrect];         btn_show.frame=cgrectmake(190+(i/2), 20, 71, 96);         [btnarray addobject:btn_show];          [btn_show setimage:[uiimage imagenamed:@"back.png"] forstate:uicontrolstatenormal];         [self.view addsubview:btn_show];         [self fun_animations:btn_show];     }      [super viewdidload];     // additional setup after loading view, typically nib. }   -(void)fun_viewanimations {     [uiview beginanimations:nil context:null];     [uiview setanimationbeginsfromcurrentstate:yes];     [uiview setanimationduration:0.2];     [uiview setanimationcurve:uiviewanimationcurveeaseinout]; }  -(void)fun_animations:(uibutton *)button {     [self fun_viewanimations];      int index=[btnarray indexofobject:button];      switch (index) {         case 0:         {             [uiview setanimationdelay:1.0];             button.frame=cgrectmake(290,10, 71, 96);         }             break;             case 1:         {             [uiview setanimationdelay:1.2];             button.frame=cgrectmake(390,110, 71, 96);         }             break;         default:             break;     }      [uiview commitanimations]; } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -