我的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)
}
}
}
更换didSelectRowAtIndexPath方法和使用didSelectRowAt(swift3.0) –