UItableView user interface not displaying correctly on ios8

I created a custom UITableViewCell , and when I show it, I have this result (I am running xcode 6 and iOS 8 beta 1 on iPhone 5.)

http://imgur.com/2MyT0mF,Nx1o4bl#0

And when I turn my device and then turn back to the portrait, everything becomes right.

http://imgur.com/2MyT0mF,Nx1o4bl#1

Please note that when I used xcode 5 to compile my application, I had no problems.

Code used in cellForRowAtIndexPath:

 BGTCoursCell1 *cell = (BGTCoursCell1 *)[tableView dequeueReusableCellWithIdentifier:@"Cell"]; NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"BGTCoursCell1" owner:self options:nil]; cell = [nib objectAtIndex:0]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"HH:mm"]; NSLocale *locale = [NSLocale currentLocale]; [dateFormatter setLocale:locale]; if (indexPath.section == 0) { BGTCours *cours = [[currentDay coursMatin] objectAtIndex:indexPath.row]; cell.matiereLabel.text = [cours matiere]; cell.salleLabel.text = [cours salle]; cell.heureLabel.text = [NSString stringWithFormat:@"De %@ Γ  %@", [dateFormatter stringFromDate:[cours beginDate]], [dateFormatter stringFromDate:[cours endDate]]]; } else { BGTCours *cours = [[currentDay coursAprem] objectAtIndex:indexPath.row]; cell.matiereLabel.text = [cours matiere]; cell.salleLabel.text = [cours salle]; cell.heureLabel.text = [NSString stringWithFormat:@"De %@ Γ  %@", [dateFormatter stringFromDate:[cours beginDate]], [dateFormatter stringFromDate:[cours endDate]]]; } return cell; 

Thanks!

+7
ios objective-c uitableview
source share
5 answers

You need to return CGFloat from tableView:heightForRowAtIndexPath: The error you see will appear if you return a float from the same method:

 //causes the bug -(float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { //... } //fixes the bug -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return tableView.rowHeight; // whatever } 
+10
source share

This question has an accepted answer, but I have the same problem that was not fixed by the accepted answer, which tells us to change float to CGFloat .

I found out that people who have code based on the rowHeight table may also have a problem. In iOS8, it's important to look at estimatedRowHeight not just rowHeight .

Since I used these variables in my programmatically generated UITableView , fixing these variables helped solve the problem.

+2
source share

Perhaps I was a bit late for the party, but I ran into the same problem with iOS 8 beta 2 and xCode 6 beta 2 today (June 26, 2014), I see that they still haven't fixed the error.

There is also another bug with the beta version of xCode 6, that is, my application cannot request the GPS location properly - it simply will not ask for permission. This is also solved by switching to xCode 5. I think at the moment it is more advisable to use xCode 5 to create and test your application.

+1
source share

try reusing the cell, e.g. change:

 BGTCoursCell1 *cell = (BGTCoursCell1 *)[tableView dequeueReusableCellWithIdentifier:@"Cell"]; NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"BGTCoursCell1" owner:self options:nil]; cell = [nib objectAtIndex:0]; 

to

 static NSString *CellIdentifier = @"Cell"; static NSString *CellNib = @"BGTCoursCell1"; BGTCoursCell1 *cell = (BGTCoursCell1 *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if( cell == nil ) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:CellNib owner:self options:nil]; cell = [nib objectAtIndex:0]; } ... return cell; 
0
source share

I had a small similar problem and it was fixed using cell.clipsToBounds = YES

0
source share

All Articles