I am making sample project to implement top menu.
Below is the project structure.
TopMenu is the parent view with structure shown below.
In TopViewController, viewDidLoad below is what I have.
NSString *whereToGo = [[NSUserDefaults standardUserDefaults] valueForKey:@"whereToGo"]; // this is DarkGray by default
UIViewController *goToViewController;
goToViewController = [self.storyboard instantiateViewControllerWithIdentifier:whereToGo];
goToViewController.view.frame = bottomView.bounds;
// bottomView is the first view (will bring child here)
[bottomView addSubview:goToViewController.view];
[self addChildViewController:goToViewController];
[goToViewController didMoveToParentViewController:self];
Now when I execute project, I see Dark Gray, but when I click on Click Me
button, nothing occurs (IBAction is not getting invoked).
- (IBAction)clickme:(id)sender {
NSLog(@"clickme==dark gray");
}
What I was expecting is when I click Click Me, I will see clickme==dark gray in log.
Any reason why this is happening?
Sample project for download
Answer
As stated by MidhunMP, short answer is
menuView was hiding bottomView
Actually, for menuView I had backgroundColor as clearColor. And I assumed (which was wrong), as menuView is clear, touches won't work on menuView and those touches will go to bottomView.