Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sgs1

macrumors newbie
Original poster
Jul 14, 2014
28
0
Hello!

I've a simple (but complicated for me) question to ask to you.
I download an ID and subcategory name from a json that is generated from a php page on my hosting.
Now, I would like to generate X uibutton of the same subcategory quantities that i've in my json.

I've developed this code, but how I can insert a distance between the uibuttons that i've generated?

Code:
for(int i=0; i<[dataArray count];i++)
    {
     
        mydata= [dataArray objectAtIndex:i];
       
        NSString *sottocategoria =[mydata objectForKey:@"sottocategoria"];
        int idsottocategoria = [[mydata objectForKey:@"ID"] integerValue];
       
        float x = gap * (i+1) + width * i;
     
        UIButton *button_sottocategoria = [UIButton buttonWithType:UIButtonTypeSystem];
           button_sottocategoria.tag = idsottocategoria;
        [button_sottocategoria setTitle:sottocategoria forState:UIControlStateNormal];
            [button_sottocategoria setFrame:CGRectMake(x,y,width,height)];
        [self.view addSubview:button_sottocategoria];

   
    }

Thanks for the help!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.