简体   繁体   English

如何从左到右进行程序化的搜索过渡?

[英]How can I make a programmatic segue transition from left to right?

I've created a UIButton that when pressed, takes my users to the home screen (acting as a "Back" button). 我创建了一个UIButton,按下该按钮会将用户带到主屏幕(充当“后退”按钮)。 Because I wanted to achieve this without the usual clunky navigation bar, I've used the below code. 因为我想在没有通常笨拙的导航栏的情况下实现此目的,所以我使用了以下代码。 However when the button is pressed, the transition goes from right to left; 但是,当按下按钮时,过渡会从右到左; how can I make the below segue transition from left to right (in a "back" motion)? 如何使下面的序列从左向右过渡(以“后退”动作)?

FullArticleViewController.m FullArticleViewController.m

-(IBAction)goBack:(id)sender {

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
    FullArticleViewController *yourViewController = (FullArticleViewController *)[storyboard instantiateViewControllerWithIdentifier:@"ArticlesViewController"];
    [self.navigationController pushViewController:yourViewController animated:YES];
}

Use this: 用这个:

[self.navigationController popViewControllerAnimated:TRUE];

This will "pop" your navigation controller stack back one view controller. 这将“弹出”您的导航控制器堆叠回一个视图控制器。 This will also prevent you from adding a view controller to the stack like you're currently doing. 这也将阻止您像现在那样将视图控制器添加到堆栈中。

You can pop multiple view controllers using something like this (just for reference): 您可以使用以下方式弹出多个视图控制器(仅供参考):

UIViewController *viewToPopTo = [self.navigationController.viewControllers objectAtIndex:([self.navigationController.viewControllers indexOfObject:self] - 2)];
[self.navigationController popToViewController:viewToPopTo animated:TRUE]; //Pops back 2

In case you you pushed the FullArticleViewController using a UINavigationController, write: 如果您使用UINavigationController推送了FullArticleViewController,请编写:

[self.navigationController popViewControllerAnimated:YES];

If you presented it modally, write: 如果您以模态展示,请输入:

[self.presentingViewController dismissViewControllerAnimated:YES];

When using a UINavigationController object the Nav Bat will be visible by default, but you can hide it if you need. 使用UINavigationController对象时,默认情况下将显示导航蝙蝠,但是您可以根据需要将其隐藏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM