gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:15:12 31 4
gpt4 key购买 nike

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

这是 Storyboard的屏幕截图:

enter image description here

在 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/

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