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;
}
任何建议表示赞赏。 谢谢。
您是如何解决这个问题的? – coder
通过打开主线程 –