You only need one tableView for searching purpose and displaying all data. Just maintain two array. First one contains your original data and second one contain the searched data. As an when search start reload tableView with 2nd array and put all data in it. Like this your navigation will work for both the scenarios.
Swift:
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
if isSearch == "true"
{
return self.searchArray.count
}
else
{
return self.arr1.count
}
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
var cell:UITableViewCell? =
tableView.dequeueReusableCellWithIdentifier("tableCell") as? UITableViewCell
if(cell == nil)
{
cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "tableCell")
cell!.selectionStyle = UITableViewCellSelectionStyle.None
}
if isSearch == "true"
{
var main_string = self.searchArray[indexPath.row]
var attributedString = NSMutableAttributedString(string:main_string)
attributedString.addAttribute(NSForegroundColorAttributeName, value: UIColor(red: 0.0/255.0, green: 168.0/255.0, blue: 255.0/255.0, alpha: 1.0) , range: NSMakeRange(0, string_to_color.length))
name.attributedText = attributedString
}
else
{
name.text = self.arr1[indexPath.row] as String
}
return cell!
}