【发布时间】:2015-05-14 10:27:54
【问题描述】:
我使用Apple sample 作为构建searchController 方案的指南。一切正常,除了我不知道如何设置 SearchResultsController 单元格的高度。
主表视图和搜索结果表都指向同一个 Nib。颜色,字体和字体大小都可以。主表视图的高度还可以。
两个控制器都指向一个有两个标签的自定义笔尖。下面是一些图片和代码片段。
任何帮助(需要检查的东西?)将不胜感激..
自定义笔尖:
这是两个控制器的 cellAtIndexPath 代码(我省略了字体和颜色信息:
main controller:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
StationCell *cell = (StationCell *)[self.tableView dequeueReusableCellWithIdentifier:kStationCellIdentifier];
currentStationArray = stationListArray[indexPath.row];
cell.stationLabel.text = [currentStationArray valueForKey:@"Name"];
NSString *tempString = [currentStationArray valueForKey:@"LineCode1"];
cell.lineLabel.text = tempString;
return cell;
}
search result controller:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//NSLog(@"%s", __FUNCTION__);
StationCell *cell = [tableView dequeueReusableCellWithIdentifier:kStationCellIdentifier];
currentStationArray = [self.selectedStations objectAtIndex:indexPath.row];
cell.stationLabel.text = [currentStationArray valueForKey:@"Name"];
cell.stationLabel.font = [UIFont fontWithName:@"OrdredeDepart" size:24];
cell.stationLabel.textColor = [UIColor yellowColor];
cell.contentView.backgroundColor = [UIColor blackColor];
cell.backgroundColor = [UIColor blackColor];
NSString *tempString = [currentStationArray valueForKey:@"LineCode1"];
cell.lineLabel.text = tempString;
return cell;
}
最后,主单元格如下所示:
和搜索结果单元格,如下所示:
【问题讨论】:
标签: objective-c uitableview ios8 uisearchcontroller