Open luhui opened 10 years ago
Onece I solved the problem use the code above, it gets nil also when I set contentView
twice before menuViewController
present.
I found that setContentView
method in REFrostedViewController
, it will reset the contentView
's frame with containerView
's frame. The code below:
- (void)setContentViewController:(UIViewController *)contentViewController
{
if (!_contentViewController) {
_contentViewController = contentViewController;
return;
}
[_contentViewController removeFromParentViewController];
[_contentViewController.view removeFromSuperview];
if (contentViewController) {
[self addChildViewController:contentViewController];
contentViewController.view.frame = self.containerViewController.view.frame;// what's this code work?
[self.view insertSubview:contentViewController.view atIndex:0];
[contentViewController didMoveToParentViewController:self];
}
_contentViewController = contentViewController;
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
}
}
Once I delete contentViewController.view.frame = self.containerViewController.view.frame;
, it works well for me.
I use
self.frostedViewController
in mymenuViewController
inviewDidLoad
method. But sometimes return isnil
and theUIButton
in mymenuViewController
can not touch, only when i close themenuViewController
and reopen it. I found that thecontainerViewController
calledviewDidload
before it added to be thefrostedViewController
'schildViewController
I fix the return nil problem with the code:But I don't know how to fix the problem
UIButton
in themenuViewController
can not response the touch gesture at first time.