草庐IT

更改 View Controller 时的 iOS 有线卡住问题

coder 2024-01-29 原文

我有一个 iOS 应用程序,它有两种在 View Controller 之间进行更改和导航的方式,第一种方式是使用带导航 Controller 的推送/弹出方式,第二种方式是使用苹果文档中的自定义容器 View Controller 的自定义转换方式,

这是 Storyboard的屏幕截图:

在 ViewController.swift 中:

var contentViewController: UIViewController! {
    didSet {
        // remove any previous views
        for view in self.contentView.subviews {
            view.removeFromSuperview()
        }

        // add the view
        // the ViewController must be aded to the children list to avoid being released (as it become a Zombie)
        self.addChildViewController(self.contentViewController)

        if registerDoneFlag {

            //do some animation
            let animation =  CATransition()
            animation.duration = 0.3
            animation.type = kCATransitionPush
            animation.subtype = kCATransitionFromTop
            animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)

            self.contentView.layer.addAnimation(animation, forKey: "SwitchToView1")

            registerDoneFlag = false
        }
        if backFlag {

            //do some animation
            let animation =  CATransition()
            animation.duration = 0.3
            animation.type = kCATransitionPush
            animation.subtype = kCATransitionFromBottom
            animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)

            self.contentView.layer.addAnimation(animation, forKey: "SwitchToView1")

            backFlag = false
        }

        self.contentView.addSubview(self.contentViewController.view)
        self.contentViewController.didMoveToParentViewController(self)
    }
}

我们在应用程序的开头制作这些动画:

func upperViewAnimation() {

    contianerTop.constant = 0
    UIView.animateWithDuration(0.45, animations: { () -> Void in

        self.view.layoutIfNeeded()

        }, completion:{(finished)  in

            if finished {

                if noInternetConnection && !noInternetConnectionPopup {

                    if isiPadFlag {

                        self.noConnectionViewHeight.constant = 60
                    }
                    else {

                        self.noConnectionViewHeight.constant = 50
                    }

                    UIView.animateWithDuration(0.3, animations: {

                        self.view.layoutIfNeeded()
                    })

                    noInternetConnectionPopup = true

                    openNoInternetConnection()

                }
                else if noInternetConnection {

                    if isiPadFlag {

                        self.noConnectionViewHeight.constant = 60
                    }
                    else {

                        self.noConnectionViewHeight.constant = 50
                    }

                    UIView.animateWithDuration(0.3, animations: {

                        self.view.layoutIfNeeded()
                    })

                }
                else {

                    self.noConnectionViewHeight.constant = 0

                    UIView.animateWithDuration(0.3, animations: {

                        self.view.layoutIfNeeded()

                        }, completion: { (finished) in

                            self.pullToRefreshAction()

                    })


                }

                self.notificationButtonAnimationAndMenuButton()
                self.moreAppsLabel.hidden = false
            }

    })

    //self.notificationButtonAnimationAndMenuButton()

}

一切正常,除了在某些情况下应用程序进入有线卡住情况,导航方式工作正常(推送/弹出)但更改 View Controller 方式根本不起作用,即使应用程序执行了 contentViewController 的集合但没有渲染应用程序没有任何变化

最佳答案

当主线程在完整的 View 加载过程中执行服务/网络请求时,我看到了类似的行为。

关于更改 View Controller 时的 iOS 有线卡住问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41999786/

有关更改 View Controller 时的 iOS 有线卡住问题的更多相关文章

  1. ruby-on-rails - Ruby on Rails 迁移,将表更改为 MyISAM - 2

    如何正确创建Rails迁移,以便将表更改为MySQL中的MyISAM?目前是InnoDB。运行原始执行语句会更改表,但它不会更新db/schema.rb,因此当在测试环境中重新创建表时,它会返回到InnoDB并且我的全文搜索失败。我如何着手更改/添加迁移,以便将现有表修改为MyISAM并更新schema.rb,以便我的数据库和相应的测试数据库得到相应更新? 最佳答案 我没有找到执行此操作的好方法。您可以像有人建议的那样更改您的schema.rb,然后运行:rakedb:schema:load,但是,这将覆盖您的数据。我的做法是(假设

  2. ruby - 在 64 位 Snow Leopard 上使用 rvm、postgres 9.0、ruby 1.9.2-p136 安装 pg gem 时出现问题 - 2

    我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po

  3. ruby - 通过 rvm 升级 ruby​​gems 的问题 - 2

    尝试通过RVM将RubyGems升级到版本1.8.10并出现此错误:$rvmrubygemslatestRemovingoldRubygemsfiles...Installingrubygems-1.8.10forruby-1.9.2-p180...ERROR:Errorrunning'GEM_PATH="/Users/foo/.rvm/gems/ruby-1.9.2-p180:/Users/foo/.rvm/gems/ruby-1.9.2-p180@global:/Users/foo/.rvm/gems/ruby-1.9.2-p180:/Users/foo/.rvm/gems/rub

  4. ruby - 通过 RVM (OSX Mountain Lion) 安装 Ruby 2.0.0-p247 时遇到问题 - 2

    我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search

  5. ruby-on-rails - 项目升级后 Pow 不会更改 ruby​​ 版本 - 2

    我在我的Rails项目中使用Pow和powifygem。现在我尝试升级我的ruby​​版本(从1.9.3到2.0.0,我使用RVM)当我切换ruby​​版本、安装所有gem依赖项时,我通过运行railss并访问localhost:3000确保该应用程序正常运行以前,我通过使用pow访问http://my_app.dev来浏览我的应用程序。升级后,由于错误Bundler::RubyVersionMismatch:YourRubyversionis1.9.3,butyourGemfilespecified2.0.0,此url不起作用我尝试过的:重新创建pow应用程序重启pow服务器更新战俘

  6. ruby - Capistrano 3 在任务中更改 ssh_options - 2

    我尝试使用不同的ssh_options在同一阶段运行capistranov.3任务。我的production.rb说:set:stage,:productionset:user,'deploy'set:ssh_options,{user:'deploy'}通过此配置,capistrano与用户deploy连接,这对于其余的任务是正确的。但是我需要将它连接到服务器中配置良好的an_other_user以完成一项特定任务。然后我的食谱说:...taskswithoriginaluser...task:my_task_with_an_other_userdoset:user,'an_othe

  7. ruby - Fast-stemmer 安装问题 - 2

    由于fast-stemmer的问题,我很难安装我想要的任何ruby​​gem。我把我得到的错误放在下面。Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingfast-stemmer:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcreatingMakefilemake"DESTDIR="cleanmake"DESTDIR=

  8. ruby - 如何验证 IO.copy_stream 是否成功 - 2

    这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下

  9. ruby - 安装 Ruby 时遇到问题(无法下载资源 "readline--patch") - 2

    当我尝试安装Ruby时遇到此错误。我试过查看this和this但无济于事➜~brewinstallrubyWarning:YouareusingOSX10.12.Wedonotprovidesupportforthispre-releaseversion.Youmayencounterbuildfailuresorotherbreakages.Pleasecreatepull-requestsinsteadoffilingissues.==>Installingdependenciesforruby:readline,libyaml,makedepend==>Installingrub

  10. Ruby 文件 IO 定界符? - 2

    我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的

随机推荐