How to pass through click event in UIView and UITableView
Hello guys, We are now have pandemic that makes many of us stay at home. Sometimes we are bored to do something at home. But we need to do something helpful for our life that's why I'm creating an app that I want to explore with MVVM architecture and new layout. Before I used to always use MVC to create an app. It's good to know other architecture like MVVM or VIPER.
I have started to like using MVVM architecture for my project. If you MVC, you would face the controllers have so many code to handle business logic and UI. If we can seperate business logic to create the class itself, it would be good. The class itself, we call it "ViewModel". We do our business logic in there. Maybe next week I will share my structure project to show you how I handle my project maintable and easy to organize.
But today I don't want to share about architecture in programming but about iOS layout as you can see above. I have two images, there's a button on top right called Show. You can click the button and It will show you another view controller. But on the second image as you can see the show button is behind another layout. It means the show button is behind another UIView. But the view itself is clear background actually.
How do we send our click to behind another UIView ? It's simple actually, first we need to know what views above button that we want to click. In my case there are two that are UIView header and UITableview. So we have to change header view to PassThroughView and UITableView to PassThroughTableView. That's it, you can check what's inside these classes.
Just be honest, I didn't create this code by my own. I got this code from google, but I forgot where the link is. This code actually subclass UIView or UITableView and then override method point. In this method it passes click event to behind the view. That's it if you have any question, please feel free to ask what it is. Thanks for visiting my simple blog.