Objective Cの - Googleの自動補完 - テーブルビュー - まず行目と2行は
をオーバーラップしている私は、私が探した場所のためのGoogleのオートコンプリートAPIを使用していますし、結果を表示するには、テーブルビューを使用しています客観C.に新しいです。
しかし、1行目と2行目がマージされています。あなたは何が問題になるのかお勧めしますか?
- (nullable NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if ((_gmsAutocompletePredictions.count || _searchBar.text.length) && section == 0) {
return "Search Result";
}
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return (_gmsAutocompletePredictions.count || _searchBar.text.length) ? 1 : 0;
}
- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if ((_gmsAutocompletePredictions.count || _searchBar.text.length) && section == 0) {
return _gmsAutocompletePredictions.count;
}
}
- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
// CPTLocationSearchCell User defined class which implements UITableViewCell
CPTLocationSearchCell * cell = [tableView dequeueReusableCellWithIdentifier:CPTLocationSearchCellID forIndexPath:indexPath];
cell.primaryLabel.attributedText = _gmsAutocompletePredictions[indexPath.row].attributedPrimaryText;
cell.secondaryLabel.attributedText = _gmsAutocompletePredictions[indexPath.row].attributedSecondaryText;
return cell;
}
// I think the problem with this function
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath: (NSIndexPath *)indexPath {
if (indexPath.section == 0 && indexPath.row == 0) {
NSLog(@"heightForRowAtIndexPath %lu %lu ",indexPath.section,indexPath.row);
return 0.0;
}
return 60;
}
カスタムテーブルビューを使用していますか? –
はいテーブルビューを使用して結果を表示しています。@ Rajesh。 –
show cellforrow code –