2016-12-22 1 views
1

Hy Jeder,UiTableView auf dem iPhone zeigt nur die erste Zeile auf iOS 10.0

Ich experimentiere ein seltsames Verhalten mit dem TableView nur auf dem iPhone. Das Problem ist, dass das UITableView, das automatisch beim Laden von Daten aktualisiert wird, nur die erste Zeile auf dem iPhone zeigen würde und beim Scrollen nach unten erscheinen die anderen Zeilen. Dieses Verhalten begann mit iOS 10.0 und nur auf dem iPhone. Auf iPad funktioniert es richtig.

- (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 [searchResultsArray count]; 
} 


// Customize the appearance of table view cells. 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 
      [[NSBundle mainBundle] loadNibNamed:@"searchResultCell" owner:self options:nil]; 
     } 
     else { 
      [[NSBundle mainBundle] loadNibNamed:@"searchResultCell~iphone" owner:self options:nil]; 
     } 


     cell = referenceCell; 
     self.referenceCell = nil; 
     self.referenceCell.tag = indexPath.row; 
    } 
    NSMutableDictionary *referenceDict = [searchResultsArray objectAtIndex:indexPath.row]; 
    UILabel *label = (UILabel *)[cell viewWithTag:3]; 
    label.text = [referenceDict objectForKey:@"TEXT"]; 

    UIView *cellView = (UIView*)[cell viewWithTag:5]; 
    BOOL colorBack = [[referenceDict objectForKey:@"COLOR"]intValue]; 
    if (colorBack) { 
     cellView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed: @"light gray.png"]]; 
    } 
    else { 
     cellView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed: @"sepia.png"]]; 
    } 
    cell.textLabel.highlightedTextColor = [UIColor blueColor]; 
    return cell; 
} 

Alle Vorschläge sind willkommen. Danke.

Antwort

0

Testen Sie die Threads, in denen der Code innerhalb von cellForRowAtIndexPath ausgeführt wird. Ich hatte ähnliche Probleme in dieser Methode in iOS10 während der Arbeit mit View-Layer

+0

Wie hast du es gelöst? – coder

+0

durch Einschalten des Hauptfadens –

Verwandte Themen