UISearchbar与UIStoryboard:segues和自定义单元格无法正常工作

Joh*_*nes 3 uisearchbar ios uistoryboard

我正在使用故事板,并希望为我的UITableView实现一个UISearchbar.UISearchbarController生成一个新的UITableView,我使用以下策略:

if (tableView == self.tableView)
   //Populate table view with normal data
else
   //Populate table view with search data
Run Code Online (Sandbox Code Playgroud)

第一个问题是处理自定义单元格.我必须在cellForRowAtIndexPath中实例化它们.通常你会从一个nib文件中做到这一点.我如何使用故事板进行此操作?dequeueReusableCellWithIdentifier返回nil.

第二个问题涉及从表视图到详细视图的segue.segue在普通表视图中启动,但不在搜索表视图中启动.由于故事板隐藏了一切,我不知道如何将segue分配给搜索表视图的单元格.

有人可以帮忙吗?谢谢!

Mah*_*dam 6

关于第一个问题我通过将ViewController类型从UITableViewController更改为UIViewController来解决它,然后在其中添加表视图并为表视图添加IBOutlet

@property (strong, nonatomic) IBOutlet UITableView *_tableView;
Run Code Online (Sandbox Code Playgroud)

使用插座将表格单元格出列

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MyTableViewCell *cell=[_tableView dequeueReusableCellWithIdentifier:productMasterCellIdentifier];
    // .. modify your cell
    return cell;
}
Run Code Online (Sandbox Code Playgroud)