ios8 searchController searchResults 自定义单元格高度错误
ios8 searchController searchResults custom cell is wrong height
我正在使用 Apple sample 作为构建 searchController 方案的指南。一切正常,除了我不知道如何设置 SearchResultsController 单元格的高度。
主 table 视图和搜索结果 table 都指向同一个 Nib。颜色,字体和字体大小都可以。主视图table的高度没问题。
两个控制器都指向一个有两个标签的自定义笔尖。下面是一些图片和代码片段。
任何帮助(要检查的东西?)将不胜感激..
自定义笔尖:
这是两个控制器的 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;
}
最后,主单元格如下所示:
和搜索结果单元格,如下所示:
您可以使用此委托方法:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 80.0f;
}
我正在使用 Apple sample 作为构建 searchController 方案的指南。一切正常,除了我不知道如何设置 SearchResultsController 单元格的高度。
主 table 视图和搜索结果 table 都指向同一个 Nib。颜色,字体和字体大小都可以。主视图table的高度没问题。
两个控制器都指向一个有两个标签的自定义笔尖。下面是一些图片和代码片段。
任何帮助(要检查的东西?)将不胜感激..
自定义笔尖:
这是两个控制器的 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;
}
最后,主单元格如下所示:
和搜索结果单元格,如下所示:
您可以使用此委托方法:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 80.0f;
}