相关疑难解决方法(0)

UISearchDisplayController和自定义单元格

我在UITableViewController中实现了一个UISearchDisplayController.搜索工作正常,但UISearhDisplayController创建一个带有标准单元格的新tableView,而我的tableView正在使用自定义单元格.另一个问题是我使用了一个segue:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 
Run Code Online (Sandbox Code Playgroud)

而且searchResultsTableView中的单元格没有触发segue ..

如何使用自定义单元格和segue工作显示搜索结果?

这是代码:

...

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (tableView == self.searchDisplayController.searchResultsTableView){ 
return [nameFilteredObj count];
} else {
return [sortedObj count];
}}

- (CustomCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"customCell";

CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {
cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
if (tableView == self.searchDisplayController.searchResultsTableView)
{
cell.textLabel.text = [[sortedObj objectAtIndex:indexPath.row] valueForKey:@"Name"];
 } else {
cell.nameLabel.text = [[sortedObj objectAtIndex:indexPath.row] valueForKey:@"Name"];
cell.countryLabel.text = [[sortedObj …
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c ios

5
推荐指数
1
解决办法
2964
查看次数

标签 统计

ios ×1

iphone ×1

objective-c ×1

xcode ×1