SwiftBlade
Published in

SwiftBlade

How to restrict selection region of cell

Normally, tapping anywhere in a UITableViewCell or UICollectionViewCell will trigger didSelectRowAt/didSelectItemAt: indexPath delegate functions.

What if we want to constrain that tapping to just within a few subviews? Like these areas below marked in red color. How can we do it?

Solution

--

--

--

Stories about Swift, Xcode, iOS and general software development

Recommended from Medium

iOS library support both Cocoapods and Swift Package Manager

Two tips I got from Apple engineers to avoid Memory Leaks and increase efficiency in SwiftUI

Flutter+Firebase — Authenticate with Twitter

Sign in with Apple -SwiftUI

Why Would You Want to Ship Your App Every Hour?

Telegram adds message reactions, in-app translation in latest update

iOS Biometric Authentication Implementation in Swift

Apple fails again to help business.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Thongchai Kolyutsakul

Thongchai Kolyutsakul

Enthusiastic iOS developer since 2009. I write about iOS, science, and self improvement tips for software engineers. Join Medium: hlung.medium.com/membership

More from Medium

Retain Cycle… Cause And Solution

The missing handbook for Continuous Integration & Continuous Deployment (start here)

Image of a typical Software Development Workplace.

True or False?

Continuously Building and Hosting our Swift DocC Documentation using Github Actions and Netlify