Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue in GridView in iphone
    primarykey
    data
    text
    <p>I am showing images on gridview. it works fine if i have 4,8,12,16 and so on images but when i have images more or less then 4,8,12 then i cant click on them. if i have 6 images then i can click on 4 images but i cant click on 5th and 6th image. </p> <p>this is my tableview code</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView_p cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *hlCellID = @"hlCellID"; UITableViewCell *hlcell = [tableView_p dequeueReusableCellWithIdentifier:hlCellID]; if(hlcell == nil) { hlcell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:hlCellID] autorelease]; hlcell.accessoryType = UITableViewCellAccessoryNone; hlcell.selectionStyle = UITableViewCellSelectionStyleNone; } int section = indexPath.section; NSMutableArray *sectionItems = [sections objectAtIndex:section]; int n = [sectionItems count]; int i=0,i1=0; while(i&lt;n){ int yy = 4 +i1*74; int j=0; for(j=0; j&lt;4;j++){ if (i&gt;=n) break; NSLog(@"Counter i %d , j %d , n %d ",i,j, n); Item *item = [sectionItems objectAtIndex:i]; CGRect rect = CGRectMake(16+75*j, yy, 65, 65); UIButton *button=[[UIButton alloc] initWithFrame:rect]; [button setFrame:rect]; //UIImage *buttonImageNormal=[UIImage imageNamed:item.image]; UIImage *buttonImageNormal = item.savedImage; [button setBackgroundImage:buttonImageNormal forState:UIControlStateNormal]; [button setContentMode:UIViewContentModeCenter]; NSString *tagValue = [NSString stringWithFormat:@"%d%d", indexPath.section+1, i]; button.tag = [tagValue intValue]; //NSLog(@"....tag....%d", button.tag); [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; [hlcell.contentView addSubview:button]; [button release]; /*UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake((75*j)-4, yy+44, 80, 12)] autorelease]; label.text = item.title; label.textColor = [UIColor blackColor]; label.backgroundColor = [UIColor clearColor]; label.textAlignment = UITextAlignmentCenter; label.font = [UIFont fontWithName:@"ArialMT" size:12]; [hlcell.contentView addSubview:label]; */ i++; } i1 = i1+1; } return hlcell; } </code></pre> <p><img src="https://i.stack.imgur.com/XsUGx.png" alt="enter image description here"></p> <pre><code>- (void)loadView { [super loadView]; sections = [[NSMutableArray alloc] init]; imagesPath = [[NSMutableArray alloc] init]; for(int s=0;s&lt;1;s++) { // 4 sections sectionPattern = [[NSMutableArray alloc] init]; for(int i=0;i&lt;9+3;i++) { // 12 items in each section NSLog(@"Loop First %d",i); //Here i am allocating images to sectionPattern and than in sections and using it later in above code NSLog(@"Loop OUt %d",i); } [sections addObject:sectionPattern]; } } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 1; } </code></pre>
    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.
    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