Reputation: 67
I am making a drawer menu.
The tableView is on top of the DrawerMenuViewController
that was addChild
to the ParentViewController
.
When you open the drawer and tap the tableView cell on DrawerMenuViewController
, there is no response.
didSelectRowAt
is not called.delegate
is set.tableView
, but I couldn't press that button (the method called in touchUpInside
wasn't called)Why can't I tap the tableView Cell
?
DrawerMenuViewController
is just to the left of ParentViewController
.
Because DrawerMenuViewController
wants to come out from the right according to swipe
- TabBarController
- NavigationController
- ParentViewController
- DrawerMenuViewController
class ParentViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
menuViewController = DrawerMenuViewController()
menuViewController.view.frame = CGRect(
x: view.frame.maxX,
y: 0,
width: view.bounds.width,
height: UIScreen.main.bounds.height)
view.addSubview(menuViewController.view)
addChild(menuViewController)
menuViewController.didMove(toParent: self)
}
}
Supplement
DrawerMenuViewController is just to the left of ParentViewController. Because DrawerMenuViewController wants to come out from the right according to swipe
Upvotes: 1
Views: 187
Reputation: 2102
Just to make sure that you've set the delegate and datasource in in the right place:
extension ParentViewController: UITableViewDelegate, UITableViewDataSource {
} and in ParentViewController's viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
XCode will ask if you want to insert required function stubs.
When you do
menuViewController.view.frame = CGRect(
x: view.frame.maxX,
y: 0,
width: view.bounds.width,
height: UIScreen.main.bounds.height)
it looks like your origin is out of bounds because of the x coordinates
Upvotes: 1