草庐IT

没有导航 Controller 的 ios segues

coder 2023-09-25 原文

我想使用 Storyboard来创建我的应用程序。 我可以找到很多关于如何将它与导航或选项卡 Controller 一起使用的信息,但我不想使用它们中的任何一个。

我的目标是创建一个具有不同 View 但不使用导航或选项卡 Controller 的应用程序。 我该怎么做?

最佳答案

在IOS storyboard中,如果你不想使用navigation,那么你就不能使用push segue。然后,您可以使用模态转场或自定义转场。在 modal segue 中,有四种转换:

  1. 垂直覆盖
  2. 水平翻转
  3. 交叉融合
  4. 部分 curl

但是,所有这些预定义的转场动画都不能预制水平滑动动画转场。如果你想使用水平滑动效果,你必须使用自定义segue。您需要像这样重写该函数:

- (void) perform
{
UIViewController *desViewController = (UIViewController *)self.destinationViewController;

UIView *srcView = [(UIViewController *)self.sourceViewController view];
UIView *desView = [desViewController view];

desView.transform = srcView.transform;
desView.bounds = srcView.bounds;

if(isLandscapeOrientation)
{
    if(isDismiss)
    {
        desView.center = CGPointMake(srcView.center.x, srcView.center.y  - srcView.frame.size.height);
    }
    else
    {
        desView.center = CGPointMake(srcView.center.x, srcView.center.y  + srcView.frame.size.height);
    }
}
else
{
    if(isDismiss)
    {
        desView.center = CGPointMake(srcView.center.x - srcView.frame.size.width, srcView.center.y);
    }
    else
    {
        desView.center = CGPointMake(srcView.center.x + srcView.frame.size.width, srcView.center.y);
    }
}


UIWindow *mainWindow = [[UIApplication sharedApplication].windows objectAtIndex:0];
[mainWindow addSubview:desView];

// slide newView over oldView, then remove oldView
[UIView animateWithDuration:0.3
                 animations:^{
                     desView.center = CGPointMake(srcView.center.x, srcView.center.y);

                     if(isLandscapeOrientation)
                     {
                         if(isDismiss)
                         {
                             srcView.center = CGPointMake(srcView.center.x, srcView.center.y + srcView.frame.size.height);
                         }
                         else
                         {
                             srcView.center = CGPointMake(srcView.center.x, srcView.center.y - srcView.frame.size.height);
                         }
                     }
                     else
                     {
                         if(isDismiss)
                         {
                             srcView.center = CGPointMake(srcView.center.x + srcView.frame.size.width, srcView.center.y);
                         }
                         else
                         {
                             srcView.center = CGPointMake(srcView.center.x - srcView.frame.size.width, srcView.center.y);
                         }
                     }
                 }
                 completion:^(BOOL finished){
                     //[desView removeFromSuperview];
                     [self.sourceViewController presentModalViewController:desViewController animated:NO];
                 }];
}

如果还有问题,可以查看这篇文章。它还有一个 youtube 视频向您展示如何实现此自定义转场:

Create Push Segue Animation Without UINavigation Controller

关于没有导航 Controller 的 ios segues,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12278845/

有关没有导航 Controller 的 ios segues的更多相关文章

  1. ruby - 难道Lua没有和Ruby的method_missing相媲美的东西吗? - 2

    我好像记得Lua有类似Ruby的method_missing的东西。还是我记错了? 最佳答案 表的metatable的__index和__newindex可以用于与Ruby的method_missing相同的效果。 关于ruby-难道Lua没有和Ruby的method_missing相媲美的东西吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/7732154/

  2. ruby-on-rails - 渲染另一个 Controller 的 View - 2

    我想要做的是有2个不同的Controller,client和test_client。客户端Controller已经构建,我想创建一个test_clientController,我可以使用它来玩弄客户端的UI并根据需要进行调整。我主要是想绕过我在客户端中内置的验证及其对加载数据的管理Controller的依赖。所以我希望test_clientController加载示例数据集,然后呈现客户端Controller的索引View,以便我可以调整客户端UI。就是这样。我在test_clients索引方法中试过这个:classTestClientdefindexrender:template=>

  3. ruby-on-rails - rails 目前在重启后没有安装 - 2

    我有一个奇怪的问题:我在rvm上安装了ruby​​onrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(

  4. ruby-on-rails - Rails 应用程序中的 Rails : How are you using application_controller. rb 是新手吗? - 2

    刚入门rails,开始慢慢理解。有人可以解释或给我一些关于在application_controller中编码的好处或时间和原因的想法吗?有哪些用例。您如何为Rails应用程序使用应用程序Controller?我不想在那里放太多代码,因为据我了解,每个请求都会调用此Controller。这是真的? 最佳答案 ApplicationController实际上是您应用程序中的每个其他Controller都将从中继承的类(尽管这不是强制性的)。我同意不要用太多代码弄乱它并保持干净整洁的态度,尽管在某些情况下ApplicationContr

  5. ruby-on-rails - rails : How to make a form post to another controller action - 2

    我知道您通常应该在Rails中使用新建/创建和编辑/更新之间的链接,但我有一个情况需要其他东西。无论如何我可以实现同样的连接吗?我有一个模型表单,我希望它发布数据(类似于新View如何发布到创建操作)。这是我的表格prohibitedthisjobfrombeingsaved: 最佳答案 使用:url选项。=form_for@job,:url=>company_path,:html=>{:method=>:post/:put} 关于ruby-on-rails-rails:Howtomak

  6. ruby - 在没有 sass 引擎的情况下使用 sass 颜色函数 - 2

    我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re

  7. ruby-on-rails - 如何在 Rails Controller Action 上触发 Facebook 像素 - 2

    我有一个ruby​​onrails应用程序。我按照facebook的说明添加了一个像素。但是,要跟踪转化,Facebook要求您将页面置于达到预期结果时出现的转化中。即,如果我想显示客户已注册,我会将您注册后转到的页面作为成功对象进行跟踪。我的问题是,当客户注册时,在我的应用程序中没有登陆页面。该应用程序将用户带回主页。它在主页上显示了一条消息,所以我想看看是否有一种方法可以跟踪来自Controller操作而不是实际页面的转化。我需要计数的Action没有页面,它们是ControllerAction。是否有任何人都知道的关于如何执行此操作的gem、文档或最佳实践?这是进入布局文件的像素

  8. 没有类的 Ruby 方法? - 2

    大家好!我想知道Ruby中未使用语法ClassName.method_name调用的方法是如何工作的。我头脑中的一些是puts、print、gets、chomp。可以在不使用点运算符的情况下调用这些方法。为什么是这样?他们来自哪里?我怎样才能看到这些方法的完整列表? 最佳答案 Kernel中的所有方法都可用于Object类的所有对象或从Object派生的任何类。您可以使用Kernel.instance_methods列出它们。 关于没有类的Ruby方法?,我们在StackOverflow

  9. ruby-on-rails - Rails 3,嵌套资源,没有路由匹配 [PUT] - 2

    我真的为这个而疯狂。我一直在搜索答案并尝试我找到的所有内容,包括相关问题和stackoverflow上的答案,但仍然无法正常工作。我正在使用嵌套资源,但无法使表单正常工作。我总是遇到错误,例如没有路线匹配[PUT]"/galleries/1/photos"表格在这里:/galleries/1/photos/1/edit路线.rbresources:galleriesdoresources:photosendresources:galleriesresources:photos照片Controller.rbdefnew@gallery=Gallery.find(params[:galle

  10. ruby-on-rails - 有没有办法为 CarrierWave/Fog 设置上传进度指示器? - 2

    我在Rails应用程序中使用CarrierWave/Fog将视频上传到AmazonS3。有没有办法判断上传的进度,让我可以显示上传进度如何? 最佳答案 CarrierWave和Fog本身没有这种功能;你需要一个前端uploader来显示进度。当我不得不解决这个问题时,我使用了jQueryfileupload因为我的堆栈中已经有jQuery。甚至还有apostonCarrierWaveintegration因此您只需按照那里的说明操作即可获得适用于您的应用的进度条。 关于ruby-on-r

随机推荐