如何在没有导航控制器的情况下在故事板中执行动画自定义转场?

发布于 2025-01-07 09:26:17 字数 406 浏览 3 评论 0原文

我需要在执行segue之前设置一些参数,所以我必须使用CUSTOM SEGUE,对吗? 在这种情况下,我会进行从一个屏幕到另一个屏幕的动画过渡,但我没有导航控制器(而且我不想插入一个!)

是否可以不使用导航控制器并使用自定义转场?

或者,是否可以为按钮设置一个操作并在执行转场之前执行一些代码行? 我找到了这个解决方案:

  • (IBAction)showDetailView:(id)sender {

    //代码

    ......

    [self PerformSegueWithIdentifier:@"ShowDetail" sender:sender];

它需要导航控制器...

谢谢大家,并对我的英语不好表示歉意!

I have the necessity to set some parameters before execute a segue, so I must use CUSTOM SEGUE, right?
In this case, I would make the transition, from a screen to another, animated but I don't have a NavigationController (and I don't want to insert one!)

Is it possible to not use a NavigationController and change views with a custom segue?

In alternative, there is the possibility to set an action for a button and execute some rows of code befor performing a segue?
I found this solution :

  • (IBAction)showDetailView:(id)sender {

    //code

    .....

    [self performSegueWithIdentifier:@"ShowDetail" sender:sender];

}

but it need navigtion controller...

thank you to all and sorry for my bad englis!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏末 2025-01-14 09:26:17

当您在 Storyboard 中创建 Segue 时,选择“modal”而不是“push”(自定义是指我认为您不需要的第三种类型)。选择segue 并使用属性检查器为其命名。在我的代码示例中,我使用名称“editTitleBlock”。

要在目标视图控制器(这将是模态视图控制器)上设置属性,请在第一个视图控制器中放置一个prepareForSegueMethod,如下所示:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"editTitleBlock"])  {
        [[segue destinationViewController] setTitleFieldString: @""];
        [[segue destinationViewController] setAltitudeFieldString:currentLocation.localizedAltitudeString];
        [[segue destinationViewController] setLocationFieldString:currentLocation.localizedCoordinateString];
        [[segue destinationViewController] setAuthorString:userName];

    if ([[segue identifier] isEqualToString:@"cancel"])  {
        // do nothing special
    }
}

要返回到第一个视图控制器,请使用:

[self dismissModalViewController animated:YES];

When you create you segue in Storyboard, select "modal" instead of "push" (custom refers to a third type which I don't think you need). Select the segue and use the attributes inspector to give it a name. In my code example I use the name "editTitleBlock".

To set properties on the destination view controller (which will be the modal view controller) put a prepareForSegueMethod in your first view controller like this:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"editTitleBlock"])  {
        [[segue destinationViewController] setTitleFieldString: @""];
        [[segue destinationViewController] setAltitudeFieldString:currentLocation.localizedAltitudeString];
        [[segue destinationViewController] setLocationFieldString:currentLocation.localizedCoordinateString];
        [[segue destinationViewController] setAuthorString:userName];

    if ([[segue identifier] isEqualToString:@"cancel"])  {
        // do nothing special
    }
}

to get back to the first view controller use:

[self dismissModalViewController animated:YES];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文