2016-11-11 5 views
0

Моя реализация tableView:didSelectRowAtIndexPath не работает.
С другой стороны, реализация салфетки делает.
Я хочу представить другую страницу при нажатии на строку таблицы.tableView: didSelectRowAtIndexPath не работает

Это мой код:

func tableView(_ tableView: UITableView, didSelectRowAtIndexPath indexPath: IndexPath) { 


    let tableCell: SearchTableViewCell = tableView.dequeueReusableCell(withIdentifier: "searchcell") as! SearchTableViewCell 


    if(self.searchstatus == "people") 
    { 
     if(useridarray.object(at: (indexPath as NSIndexPath).row) as! NSString != "null") 
     { 

      self.searchdelegate.otheruserid=useridarray.object(at: (indexPath as NSIndexPath).row) as! NSString; 
      let ProfilePageViewController = self.storyboard?.instantiateViewController(withIdentifier: "otherprofile") 
      self.present(ProfilePageViewController!, animated: false, completion: nil) 
     } 
    } 
    else 
    { 
     if(useridarray.object(at: (indexPath as NSIndexPath).row) as! NSString != "null") 
     { 
      let hashtag1=search.text!.replacingOccurrences(of: "#", with: "") 
      self.searchdelegate.hashtag="\(hashtag1)" as NSString! 
      self.searchdelegate.hashtag=searchdelegate.hashtag.trimmingCharacters(in: CharacterSet.whitespaces) as NSString! 
      self.searchdelegate.hashtag=searchdelegate.hashtag.replacingPercentEscapes(using: String.Encoding.utf8.rawValue) as NSString! 
      let hashtag = self.storyboard?.instantiateViewController(withIdentifier: "hashtag") 
      self.present(hashtag!, animated: false, completion: nil) 
     } 

    } 

} 

enter image description here

+0

Заменить didSelectRowAtIndexPath и использовать didSelectRowAt (swift3.0) –

ответ

2

Используйте этот метод, которые swift3.0

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 
} 
+0

Спасибо @ yogendra, но все еще didSelect не может работать для меня ??? – mouni

+0

Mouni ... пожалуйста, проверьте, что ваш выбор tableView установлен на false .... Добавить эти строки в ваш вид загрузили tableView.allowsSelection = true; – shafi

+0

@shafi Я тоже буду кодировать ... Но все же это работа для меня !! – mouni

Смежные вопросы