Note that there are some explanatory texts on larger screens.

plurals
  1. POAlways missing one row in UITableView
    primarykey
    data
    text
    <p>I created a UITableView programmatically (not using a XIB). It reads a *.plist file containing an NSMutableArray of NSDictionary objects. The problem I am experiencing is this: When I display the objects in the UITableView, it never shows the object at row zero. I know this because I get the following NSLog output:</p> <pre><code>2009-06-01 10:02:34.566 Color[784:20b] array count = 4 2009-06-01 10:02:34.570 Color[784:20b] row = 3: Air 2009-06-01 10:02:34.570 Color[784:20b] row = 2: Earth 2009-06-01 10:02:34.571 Color[784:20b] row = 1: Water 2009-06-01 10:02:34.571 Color[784:20b] row = 0: Fire </code></pre> <p>What I will see, in this case, is a table with Water, Earth, and Air (but no Fire). If I add another object, then Fire will appear but the new object will not. Therefore, it is <em>always</em> the object at row 0.</p> <p>Here is some relevant code:</p> <pre><code>@interface LoadViewController : UITableViewController &lt;UITableViewDelegate, UITableViewDataSource&gt; { NSMutableArray *loadedObjects; } - (void)viewWillAppear:(BOOL)animated { self.loadedObjects = [self getCurrentData]; NSLog(@"array count = %d", [self.loadedObjects count]); [self.tableView reloadData]; [super viewWillAppear:animated]; } -(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section { return [self.loadedColors count]; } -(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { static NSString *Identifier = @"Identifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Identifier]; if(cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:Identifier] autorelease]; cell.showsReorderControl = YES; } NSUInteger row = [indexPath row]; NSDictionary *obj = [self.loadedObjects objectAtIndex:row]; cell.text = [obj objectForKey:@"Name"]; NSLog(@"row = %d: %@", row, [obj objectForKey:@"Name"]); return cell; } </code></pre> <p>In the code snippets you can also see my output to NSLog.</p> <p>When I had populated UITableViews from a NIB I had never experienced this problem. Any suggestions are appreciated.</p> <p>Thank you in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
 

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