Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use lazy loading in UIButton image?
    primarykey
    data
    text
    <p>I use this logic for creating button in scroll view. `int m=0; int j = [imageData count]/3; int s = [imageData count]%3; if(s==1 || s==2) { j=j+1; } scrollView.contentSize = CGSizeMake(320,j*155);</p> <pre><code> int i,k,x=0,y=0; for(i=0;i&lt;j;i++) { if(s==0){ for(k=0;k&lt;3;k++) { button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setFrame:CGRectMake(13+x,10+y, 91,135)]; int p; NSLog(@"%i",p++); [button setTag:m]; [button setBackgroundColor:[UIColor whiteColor]]; NSData *imagesubCategoryData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:[imageData objectAtIndex:m]]]; [button setImage:[UIImage imageWithData:imagesubCategoryData] forState:UIControlStateNormal]; [button addTarget:self action:@selector(buttonPress:) forControlEvents:UIControlEventTouchUpInside]; [scrollView addSubview:button]; x=x+101; m++; } } else if(s==1) { for(k=0;k&lt;3;k++) { button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setFrame:CGRectMake(13+x,10+y, 91,135)]; [button setTitle:@"Button" forState:UIControlStateNormal]; int p; NSLog(@"%i",p++); [button setTag:m]; [button setBackgroundColor:[UIColor whiteColor]]; NSData *imagesubCategoryData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:[imageData objectAtIndex:m]]]; [button setImage:[UIImage imageWithData:imagesubCategoryData] forState:UIControlStateNormal]; [button addTarget:self action:@selector(buttonPress:) forControlEvents:UIControlEventTouchUpInside]; [scrollView addSubview:button]; x=x+101; if(i==j-1 &amp;&amp; k==0) { break; } m++; } } else if(s==2) { for(k=0;k&lt;3;k++) { button = [UIButton buttonWithType:UIButtonTypeCustom];; [button setFrame:CGRectMake(13+x,10+y, 91,135)]; [button setTitle:@"Button" forState:UIControlStateNormal]; int p; NSLog(@"%i",p++); [button setTag:m]; [button setBackgroundColor:[UIColor whiteColor]]; NSData *imagesubCategoryData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:[imageData objectAtIndex:m]]]; [button setImage:[UIImage imageWithData:imagesubCategoryData] forState:UIControlStateNormal]; [button addTarget:self action:@selector(buttonPress:) forControlEvents:UIControlEventTouchUpInside]; [scrollView addSubview:button]; x=x+101; if(i==j-1 &amp;&amp; k==1) { break; } m++; } } x=0; y=y+145; } </code></pre> <p>`</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload