2016-12-22 40 views
1

Hy每個人,iPhone上的UiTableView僅顯示iOS 10.0上的第一行

我正在試驗一個奇怪的行爲,只在iPhone上使用tableView。 問題是,加載數據時自動更新的UITableView只會顯示在iPhone上的第一行,並向下滾動其他行時開始出現,此行爲從iOS 10.0開始,僅在iPhone上。在iPad上它可以正常工作。

- (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; 
} 

任何建議表示讚賞。 謝謝。

回答

0

測試代碼在cellForRowAtIndexPath中運行的線程。我在iOS10中使用這種方法遇到了類似的問題,同時使用視圖層

+0

您是如何解決這個問題的? – coder

+0

通過打開主線程 –

相關問題