我有一个侧边导航控制器,并通过UIButton呈现它。当我通过
[self presentviewcontroller: NC animated: YES completion: nil]
将此NC直接设置为根视图控制器时,由于某种原因,NC的菜单侧面被一个UITransitionView
阻挡,我无法让它消失。
我已经尝试了以下方法:
UIWindow *window = [(AppDelegate *)[[UIApplication sharedApplication] delegate] window];
window.backgroundColor = kmain;
CATransition* transition = [CATransition animation];
transition.duration = .5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromTop;
[nc.view.layer addAnimation:transition forKey:kCATransition];
[UIView transitionWithView:window
duration:0.5
options:UIViewAnimationOptionTransitionNone
animations:^{ window.rootViewController = nc; }
completion:^(BOOL finished) {
for (UIView *subview in window.subviews) {
if ([subview isKindOfClass:NSClassFromString(@"UITransitionView")]) {
[subview removeFromSuperview];
}
}
}];
但这种方法非常不专业,由于窗口的根视图控制器在转换过程中会发生变化,因此会有一些卡顿,导航控制器和右上角的一部分会变黑,看起来非常糟糕。