{"id":1214,"date":"2017-10-15T16:12:35","date_gmt":"2017-10-15T07:12:35","guid":{"rendered":"http:\/\/blue-bear.jp\/kb\/?p=1214"},"modified":"2017-10-15T16:12:35","modified_gmt":"2017-10-15T07:12:35","slug":"swift4-how-to-disable-tableview-tap-on-each-tableview-cell","status":"publish","type":"post","link":"https:\/\/blue-bear.jp\/kb\/swift4-how-to-disable-tableview-tap-on-each-tableview-cell\/","title":{"rendered":"[swift4] How to disable TableView Tap on each TableView Cell"},"content":{"rendered":"<p>How to disable TableView Tap on each TableView Cell, is below code<\/p>\n<p>&nbsp;<\/p>\n<p>Setup Cell for un-selected(gray) with tap<\/p>\n<pre>\r\n    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {\r\n\r\n    let cell = tableView.dequeueReusableCell(withIdentifier: \"Cell\", for: indexPath)\r\n\r\n    if indexPath.row == 1 {\r\n        \/\/ Disable Selected Color evenif tapped       \r\n        cell.selectionStyle = UITableViewCellSelectionStyle.none\r\n    }\r\n\r\n    return cell\r\n\r\n    }\r\n<\/pre>\n<p>Setup not to pass indexPath info to didSelectRowAt evenif tapped<\/p>\n<pre>\r\n   func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {\r\n       \r\n        switch indexPath.row {\r\n        case 0:\r\n            return indexPath;\r\n        \/\/ if nil, indexPath info won't be passed to didSelectRowAt method\r\n        case 1:\r\n            return nil;\r\n\r\n        default:\r\n            return indexPath;\r\n        }\r\n        \r\n    }\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>How to disable Table<\/p>\n","protected":false},"author":1,"featured_media":88,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/1214"}],"collection":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/comments?post=1214"}],"version-history":[{"count":1,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/1214\/revisions"}],"predecessor-version":[{"id":1215,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/1214\/revisions\/1215"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media\/88"}],"wp:attachment":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media?parent=1214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/categories?post=1214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/tags?post=1214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}