你好,可爱的读者,
我已经坚持了2天,所以我真的希望有人可以帮我解决这个问题。使用Xcode 5.1.1切换视图时出现黑屏。我在stackoverflow上看到了这个问题,但没有帖子帮助我。
我想从视图Inscription切换到查看Connexion,并能够从视图Connexion切换回查看Inscription。 我用动画做,这是来自InscriptionViewController.m的代码:
- (IBAction)swipeGestureToRight:(UISwipeGestureRecognizer *)sender { // Switch à la vue de connexion
// get the view that's currently showing
UIView *currentView = self.view;
// get the the underlying UIWindow, or the view containing the current view
UIView *theWindow = [currentView superview];
ConnexionViewController *vc = [[ConnexionViewController alloc] init];
UIView *newView = vc.view;
// remove the current view and replace with myView1
[currentView removeFromSuperview];
[theWindow addSubview:newView];
// set up an animation for the transition between the views
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[theWindow layer] addAnimation:animation forKey:@"SwitchView"];
}
这是来自ConnexionViewController的代码:
- (IBAction)swipeGestureToLeft:(UISwipeGestureRecognizer *)sender {
[self dismissViewControllerAnimated:NO completion:nil];
}
你们觉得怎么样?哪里可以来的?
提前感谢您的时间和帮助。 :)
PS:我试图删除所有这些并替换为
ConnexionViewController *vc = [[ConnexionViewController alloc] init];
[self presentViewController:vc animated:NO completion:nil];
我仍然有黑屏。
编辑:解决了问题。谢谢你的帮助。 2天后我发现了。
以下是解决方案:
// get the view that's currently showing
UIView *currentView = self.view;
// get the the underlying UIWindow, or the view containing the current view
UIView *theWindow = [currentView superview];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ConnexionViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"ConnexionViewController"];
UIView *newView = vc.view;
// remove the current view and replace with myView1
[currentView removeFromSuperview];
[theWindow addSubview:newView];
// set up an animation for the transition between the views
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[theWindow layer] addAnimation:animation forKey:@"SwitchView"];
答案 0 :(得分:0)
嘿,我在xcode 5.1.1中面对同样的事情。
而不是presentViewController,我遇到了pushViewController
问题是xcode无法在我的情况下自动选择controller.xib文件,所以我添加了xib名称
最初 -
在 -
它解决了我的问题,希望它也能解决某人的问题。 :)