Jad*_*ift 0 iphone xcode back-button ios segue
我试图建立我的自定义SEGUE,在行为标准推SEGUE相似,但在我的情况下,我想使用自定义按钮屏幕间切换(无标签栏会适合这个应用程序,任何模式赛格瑞是没有好或者) .主屏幕是自定义图形,屏幕是一个地图.用户选择地图上的点,点击完成并返回主屏幕及其坐标.我正在尝试将ViewControllers与自定义segue连接起来.
我在互联网上研究了很多解决方案并找到了一个可以适应的解决方案,但代码分散在ViewControllers和AppDelegate周围(我不确定Apple是否会接受它).我正在尝试将整个代码放到CustomSegue.m/h.成功是部分的,因为使用技术(下面)它会分割到第二个ViewControler,但我无法弄清楚如何解除第二个并回到主屏幕.我尝试了各种技术,但是当我运行它时,编译器会终止带有大量错误的应用程序.在构建和运行之前既没有错误也没有警告.我还尝试使用[self dismissModalViewControllerAnimated:YES]按钮解除它; 或[self dismissViewControllerAnimated:YES completion:nil]; 当我尝试模态segues但我的代码结果不好时,它们会工作.
有没有人有一个简洁的方法来做这个.我在最近几天堆积了这个问题.我看到很多应用程序中的那种segues转换,所以它似乎非常流行,简单的解决方案.我对Xcode只有几个月的经验不多.这是我的自定义segue(使用QuartzCore动画).
#import "CustomTabBarSegue.h"
@implementation CustomTabBarSegue
-(void)perform {
UIViewController *src = (UIViewController*)[self sourceViewController];
UIViewController *dst = (UIViewController*)[self destinationViewController];
UIView *currentView = src.view;
UIView *theWindow = [currentView superview];
UIView *newView = dst.view;
[theWindow addSubview:newView];
CATransition *transition = [CATransition animation];
transition.delegate = self;
transition.duration = 1;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromRight;
[[theWindow layer] addAnimation:transition forKey:@"MySegue"];
}
@end
Run Code Online (Sandbox Code Playgroud)
下面是来自destinationVC的我的按钮的代码.(不起作用)
- (IBAction)dismiss:(id)sender
Run Code Online (Sandbox Code Playgroud)
{
[self dismissViewControllerAnimated:YES completion:^() {
[self performSegueWithIdentifier:@"MySegue" sender:self];
}];
Run Code Online (Sandbox Code Playgroud)
}
我想我可以理解你想要做什么.如果我错了,请纠正我.你想去一个视图,然后按一个后退按钮回来.正确?用故事板做这件事很容易.将NavigationController作为初始视图,并将导航控制器的根视图控制器设置为主菜单.从那里你想做一个PUSH segue并回去你想要做一个POP.
调用push segue是调用segue的常用方法,但pop有点不同.弹出一个视图的代码是:[self.navigationController popViewControllerAnimated:YES];.弹出回根视图控制器的代码是:[self.navigationController popToRootViewControllerAnimated:YES];.
我相信这就是你想要做的.不需要自定义segues.
| 归档时间: |
|
| 查看次数: |
7003 次 |
| 最近记录: |