Search code examples
iosdelegatesscrollviewcall

ios delegate and scrollView Invalid


I write this in a UIViewController but the things in the menuVC like delegate and scrollView doesn't work anymore, what happened

MuneScrollViewViewController *muneVC =[[MuneScrollViewViewController alloc]init]; 
muneVC.view.frame = CGRectMake(0,0, self.view.frame.size.width, 30); 
[self.view addSubview:muneVC.view];

Solution

  • I suspect that menuVC is dealocated, and only its view exist on screen, that may be the problem why delegates did not work. You can make the menuVC a strong property on your view controller, so it will not be dealocated when your method is finished.

    Or better set your menuVC as child controller

    self.addChildViewController(menuVC)