Search code examples
uitableviewios7ios8xcode6-beta6

UITableView works in iOS 7 but appears crushed in iOS 8


Still new to iOS programming here. Have a UITableView that works perfect on iOS 7 but appears crushed in iOS 8. Multiple devices. Also exhibits the same problem/difference when using the simulators (iOS 7 vs. iOS 8 simulators).

I am on Xcode 6 beta 6, Yosemite beta 6, iOS 7.12 and iOS 8 beta 5.

I've made the code as simple and complete as possible to show the problem:

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        // Return the number of sections.
        return 1;
    }

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        // Return the number of rows in the section.
        return [self.numberOfDays count];
    }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

        static NSString *CellIdentifier = @"Cell";

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier ];

        NSLog (@"%li", (long)indexPath.row);

        UILabel *label;
        label = (UILabel *)[cell viewWithTag:1];
        label.text = @"Monday";

        return cell;
    }

Notice my NSLog statement. There are 88 rows in my UIViewTable (0-87).

  • When this table loads in iOS 7...

    • I get 12 lines in my console
    • Which makes since as that is the initial number of viewable rows
    • The table scrolls nice and smooth ... all is good with the world.
  • When this table loads in iOS 8...

    • I get 88 lines in my console
    • Which doesn't make sense, to me anyway
    • The initial appearance of the Table looks good
    • e.g. the first 12 rows display correctly
    • The table does not scroll correctly.
    • rows 12-87 appear about 1 pixel tall.

The initial appearance of the table looks OK (e.g. the first 12 rows display correctly) until I attempt to scroll thru it. Then rows 12-87 appear about 1 pixel tall.

PLEASE HELP!

OK - it was as simple as adding: tableView.rowHeight = 44; after my static NSString *CellIdentifier = @"Cell"; line. I didn't need this is iOS 7, not sure why I need it in iOS 8.


Solution

  • OK - it was as simple as adding:

        tableView.rowHeight = 44; 
    

    after my

        static NSString *CellIdentifier = @"Cell"; 
    

    line. I didn't need this is iOS 7, not sure why I need it in iOS 8.