gpt4 book ai didi

ios - 展开 2 个 View Controller 的转场

转载 作者:行者123 更新时间:2023-12-01 18:15:20 27 4
gpt4 key购买 nike

我在 View Controller 上有一个按钮(后退按钮)。到目前为止很简单。
我有 2 个 View Controller ,每个 Controller 都有一个表。
如果用户从任一表中选择一行,它将转到 View Controller 并打开后退按钮。
后退按钮需要返回到用户选择行时所在的原始 View Controller 。

我正在考虑为此展开转场,这很好,但我不能在一个按钮上添加两个转场。一个用于返回一个 TableView ,一个用于返回另一个 TableView ,具体取决于它们用于访问 View Controller 的 TableView 。

有任何想法吗 ?

最佳答案

正如沃尔克解释的那样,

-(IBAction)devDismiss
{
NSLog(@" ------- dev dismiss .....");

// for a custom segue unwind, you must do this...
[self performSegueWithIdentifier:@"specialWord" sender:self];

// "specialWord" is the identifier set on storyboard for the
// custom unwind segue

/* for a "default" unwind segue, do this...
[self dismissViewControllerAnimated:YES completion:nil];
Note, if you used a push segue, you should use
[self.navigationController popViewControllerAnimated:YES]
If you used a modal segue, you should use
[self dismissViewControllerAnimated:YES completion:nil] "
*/
}

请注意,确实,您还必须在 segueForUnwindingToViewController: 覆盖中使用“specialWord”,这将位于 DESTINATION(即 ORIGINAL) View Controller 中,即位于下方的 View Controller 中。
-(UIStoryboardSegue *)segueForUnwindingToViewController:
(UIViewController *)toViewController
fromViewController:(UIViewController *)fromViewController
identifier:(NSString *)identifier
{
NSLog(@"we're in _your class name_, segueForUnwindingToViewController %@",
identifier);

// for some unwinds, we have a custom unwind we want to use.
// so, check the identifier:
if ([identifier isEqualToString:@"specialWord"])
{
YourCustomUnwindSegue *sg = [[YourCustomUnwindSegue alloc]
initWithIdentifier:identifier
source:fromViewController
destination:toViewController];
return sg;
}

// don't forget the break-away "return" inside any macthes.

// NSLog(@"note, if this message appears, it's likely you have a typo
// somewhere for 'specialWord' - unless you genuinely have a situation
// where it will also fall through to the 'default' unwind segue :O ");

// BE SURE TO return the default unwind segue otherwise
return [super segueForUnwindingToViewController:toViewController
fromViewController:fromViewController
identifier:identifier];
}

关于ios - 展开 2 个 View Controller 的转场,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22527305/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com