Note that there are some explanatory texts on larger screens.

plurals
  1. POTable cell's image gets disappear when scroll
    primarykey
    data
    text
    <p>This is how my table view looks. <img src="https://i.stack.imgur.com/4AE1O.png" alt="TableView"></p> <p>here is my code This is what happens when I scroll down <img src="https://i.stack.imgur.com/EjaUs.png" alt="Image with bug"> <strong>ViewController.h</strong></p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface ViewController : UIViewController&lt;UITableViewDataSource,UITableViewDelegate&gt; { NSMutableArray *items ; } @property (nonatomic,retain) NSMutableArray *items ; @end </code></pre> <p><strong>ViewController.m</strong></p> <pre><code>#import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize items; - (void)viewDidLoad { [super viewDidLoad]; items = [[NSMutableArray alloc] init]; [items addObject:@"bla bla bla"]; [items addObject:@"rikifhdif bla bla"]; [items addObject:@"bla sdfkndskfnlk bla"]; [items addObject:@"sdf,nsdmf bla bla"]; [items addObject:@"sdjkfhksd bla bla"]; [items addObject:@"dkfhkusd bla bla"]; [items addObject:@"bla sdfjknskdjf bla"]; [items addObject:@"kiidrfjifig jjojdjfgdfgjjdjsjkhksidfl"]; [items addObject:@"mksjdhf ysdgjg bla"]; // Do any additional setup after loading the view, typically from a nib. } #pragma tableview logic -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 6; } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { if(section == 0) { return @"Title0"; } else if(section == 1) { return @"Title1"; } else if(section == 2) { return @"Title2"; } if(section == 3) { return @"Title3"; } else if(section == 4) { return @"Title4"; } else { return @"Title5"; } } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (section==0) { return 3; } if (section==1) { return 1; } if (section==2) { return 2; } if (section==3) { return 2; } if (section==4) { return 1; } if (section==5) { return 1; } return 1; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } cell.textLabel.text = [items objectAtIndex:indexPath.row]; cell.imageView.image = [UIImage imageNamed:@"Star.jpg"]; switch (indexPath.section) { case 0: if (indexPath.row==1) { [[cell imageView] setHidden:YES]; } if (indexPath.row==2) { [[cell imageView] setHidden:YES]; } break; case 1: if (indexPath.row==1) { [[cell imageView] setHidden:YES]; } if (indexPath.row==2) { [[cell imageView] setHidden:YES]; } break; case 2: if (indexPath.row==1) { [[cell imageView] setHidden:YES]; } if (indexPath.row==2) { [[cell imageView] setHidden:YES]; } break; case 3: if (indexPath.row==1) { [[cell imageView] setHidden:YES]; } if (indexPath.row==2) { [[cell imageView] setHidden:YES]; } break; case 4: if (indexPath.row==1) { [[cell imageView] setHidden:YES]; } if (indexPath.row==2) { [[cell imageView] setHidden:YES]; } break; case 5: if (indexPath.row==1) { [[cell imageView] setHidden:YES]; } if (indexPath.row==2) { [[cell imageView] setHidden:YES]; } break; default: break; } return cell; //} } - (void)dealloc { [items release], items = nil; [super dealloc]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end </code></pre> <p>Just want to show image for the first row of every section. The output is ok at the time of loading but when I scroll the view the first image gets disappear. How Do I fix this issue?? Any help would be appreciated. many thanks in advance.</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