UIViewControllerAnimatedTransitioning:旋转更改后黑屏片段

2024-06-20

我已经创建了一个视图控制器转换,只要我不更改设备方向,一切都正常。

图 1 显示了应有的屏幕。然后我切换到下一个视图控制器,在其中更改方向。现在我回到第一个视图控制器并再次切换方向。然后我得到的结果如图 2 所示。出现黑色边框。请不要介意屏幕中央的白框。

下面你可以找到我的动画的代码。你能看出哪里出了问题吗?

import Foundation

import UIKit

class ZoomOutCircleViewTransition: NSObject, UIViewControllerAnimatedTransitioning, UIViewControllerTransitioningDelegate {

    var hideDelayed = false
    var transitionContext: UIViewControllerContextTransitioning?

    init(hideDelayed : Bool = true) {
        self.hideDelayed = hideDelayed
        super.init()
    }


    func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
        return 0.6
    }

    func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
        self.transitionContext = transitionContext

        guard let toViewController: UIViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey) else {
            return
        }

        guard let fromViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey) else {
            return
        }

        guard let toViewTransitionFromView = toViewController as? TransitionFromViewProtocol else {
            return
        }

        let containerView = transitionContext.containerView()

        let imageViewSnapshot = toViewTransitionFromView.getViewForTransition()
        imageViewSnapshot.alpha = 0.0
        let imageViewSnapshotOriginalFrame = imageViewSnapshot.frame

        let startFrame = CGRectMake(-CGRectGetWidth(toViewController.view.frame)/2, -CGRectGetHeight(toViewController.view.frame)/2, CGRectGetWidth(toViewController.view.frame)*2, CGRectGetHeight(toViewController.view.frame)*2)

        let quadraticStartFrame = CGRect(x: startFrame.origin.x - (startFrame.height - startFrame.width)/2, y: startFrame.origin.y, width: startFrame.height, height: startFrame.height)

        containerView!.insertSubview(toViewController.view, atIndex: 0)
        containerView!.addSubview(imageViewSnapshot)


        // UIViewController circle shrink animation
        let bigCirclePath = UIBezierPath(ovalInRect: quadraticStartFrame)

        let smallCirclePath = UIBezierPath(ovalInRect: imageViewSnapshot.frame)
        let maskLayer = CAShapeLayer()
        maskLayer.frame = toViewController.view.frame
        maskLayer.path = bigCirclePath.CGPath//maskPath.CGPath
        fromViewController.view.layer.mask = maskLayer

        let pathAnimation = CABasicAnimation(keyPath: "path")
        pathAnimation.delegate = self
        pathAnimation.fromValue = bigCirclePath.CGPath
        pathAnimation.toValue = smallCirclePath.CGPath
        pathAnimation.duration = transitionDuration(transitionContext)
        maskLayer.path = smallCirclePath.CGPath
        maskLayer.addAnimation(pathAnimation, forKey: "pathAnimation")

        //        pathAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)

        imageViewSnapshot.frame = quadraticStartFrame

        // Make imageView visible with animation
        let showImageViewAnimation =  {
            imageViewSnapshot.alpha = 1.0
        }
        let showImageViewDelay = 0.3
        UIView.animateWithDuration(transitionDuration(transitionContext) - showImageViewDelay , delay: showImageViewDelay, options: UIViewAnimationOptions.CurveLinear, animations: showImageViewAnimation) { (completed) -> Void in
        }

        // Shrink the imageView to the original size
        let scaleImageViewAnimation = {
            imageViewSnapshot.frame = imageViewSnapshotOriginalFrame
        }
        UIView.animateWithDuration(transitionDuration(transitionContext), delay: 0.0, options: UIViewAnimationOptions.CurveLinear, animations: scaleImageViewAnimation) { (completed) -> Void in
            // After the complete animations have endet

            // Hide ImageView after it is completely resized. Added some animation delay to not abruptly change the contactImage
            if self.hideDelayed {
                let hideImageViewAnimation =  {
                    imageViewSnapshot.alpha = 0.0
                }
                UIView.animateWithDuration(0.2 , delay: 0.2, options: UIViewAnimationOptions.CurveLinear, animations: hideImageViewAnimation) { (completed) -> Void in
                    imageViewSnapshot.removeFromSuperview()
                }
            }
            else {
                imageViewSnapshot.removeFromSuperview()
            }
        }
    }

    override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
        if let transitionContext = self.transitionContext {
            transitionContext.completeTransition(!transitionContext.transitionWasCancelled())
        }
    }

    // MARK: UIViewControllerTransitioningDelegate protocol methods

    // return the animataor when presenting a viewcontroller
    func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return self
    }

    // return the animator used when dismissing from a viewcontroller
    func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return self
    }

}

您需要将新框架设置为 toViewController.view。这会将视图更新为当前方向。

toViewController.view.frame = fromViewController.view.frame

使用我更新的代码:

class ZoomOutCircleViewTransition: NSObject, UIViewControllerAnimatedTransitioning, UIViewControllerTransitioningDelegate {

    var hideDelayed = false
    var transitionContext: UIViewControllerContextTransitioning?

    init(hideDelayed : Bool = true) {
        self.hideDelayed = hideDelayed
        super.init()
    }


    func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
        return 0.6
    }

    func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
        self.transitionContext = transitionContext

        guard let toViewController: UIViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey) else {
            return
        }

        guard let fromViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey) else {
            return
        }

        guard let toViewTransitionFromView = toViewController as? TransitionFromViewProtocol else {
            return
        }

        toViewController.view.frame = fromViewController.view.frame

        let containerView = transitionContext.containerView()

        let imageViewSnapshot = toViewTransitionFromView.getViewForTransition()
        imageViewSnapshot.alpha = 0.0
        let imageViewSnapshotOriginalFrame = imageViewSnapshot.frame

        let startFrame = CGRectMake(-CGRectGetWidth(fromViewController.view.frame)/2, -CGRectGetHeight(fromViewController.view.frame)/2, CGRectGetWidth(toViewController.view.frame)*2, CGRectGetHeight(toViewController.view.frame)*2)

        let quadraticStartFrame = CGRect(x: startFrame.origin.x - (startFrame.height - startFrame.width)/2, y: startFrame.origin.y, width: startFrame.height, height: startFrame.height)

        containerView!.insertSubview(toViewController.view, atIndex: 0)
        containerView!.addSubview(imageViewSnapshot)


        // UIViewController circle shrink animation
        let bigCirclePath = UIBezierPath(ovalInRect: quadraticStartFrame)

        let smallCirclePath = UIBezierPath(ovalInRect: imageViewSnapshot.frame)
        let maskLayer = CAShapeLayer()
        maskLayer.frame = toViewController.view.frame
        maskLayer.path = bigCirclePath.CGPath//maskPath.CGPath
        fromViewController.view.layer.mask = maskLayer

        let pathAnimation = CABasicAnimation(keyPath: "path")
        pathAnimation.delegate = self
        pathAnimation.fromValue = bigCirclePath.CGPath
        pathAnimation.toValue = smallCirclePath.CGPath
        pathAnimation.duration = transitionDuration(transitionContext)
        maskLayer.path = smallCirclePath.CGPath
        maskLayer.addAnimation(pathAnimation, forKey: "pathAnimation")

        //        pathAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)

        imageViewSnapshot.frame = quadraticStartFrame

        // Make imageView visible with animation
        let showImageViewAnimation =  {
            imageViewSnapshot.alpha = 1.0
        }
        let showImageViewDelay = 0.3
        UIView.animateWithDuration(transitionDuration(transitionContext) - showImageViewDelay , delay: showImageViewDelay, options: UIViewAnimationOptions.CurveLinear, animations: showImageViewAnimation) { (completed) -> Void in
        }

        // Shrink the imageView to the original size
        let scaleImageViewAnimation = {
            imageViewSnapshot.frame = imageViewSnapshotOriginalFrame
        }
        UIView.animateWithDuration(transitionDuration(transitionContext), delay: 0.0, options: UIViewAnimationOptions.CurveLinear, animations: scaleImageViewAnimation) { (completed) -> Void in
            // After the complete animations have endet

            // Hide ImageView after it is completely resized. Added some animation delay to not abruptly change the contactImage
            if self.hideDelayed {
                let hideImageViewAnimation =  {
                    imageViewSnapshot.alpha = 0.0
                }
                UIView.animateWithDuration(0.2 , delay: 0.2, options: UIViewAnimationOptions.CurveLinear, animations: hideImageViewAnimation) { (completed) -> Void in
                    imageViewSnapshot.removeFromSuperview()
                }
            }
            else {
                imageViewSnapshot.removeFromSuperview()
            }
            toViewController.view.layer.mask = nil
        }
    }

    override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
        if let transitionContext = self.transitionContext {
            transitionContext.completeTransition(!transitionContext.transitionWasCancelled())
        }
    }

    // MARK: UIViewControllerTransitioningDelegate protocol methods

    // return the animataor when presenting a viewcontroller
    func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return self
    }

    // return the animator used when dismissing from a viewcontroller
    func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return self
    }

}

class ZoomOutCircleViewTransition: NSObject, UIViewControllerAnimatedTransitioning, UIViewControllerTransitioningDelegate {

    var hideDelayed = false
    var transitionContext: UIViewControllerContextTransitioning?

    init(hideDelayed : Bool = true) {
        self.hideDelayed = hideDelayed
        super.init()
    }


    func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
        return 0.6
    }

    func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
        self.transitionContext = transitionContext

        guard let toViewController: UIViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey) else {
            return
        }

        guard let fromViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey) else {
            return
        }

        guard let toViewTransitionFromView = toViewController as? TransitionFromViewProtocol else {
            return
        }

        toViewController.view.frame = fromViewController.view.frame

        let containerView = transitionContext.containerView()

        let imageViewSnapshot = toViewTransitionFromView.getViewForTransition()
        imageViewSnapshot.alpha = 0.0
        let imageViewSnapshotOriginalFrame = imageViewSnapshot.frame

        let startFrame = CGRectMake(-CGRectGetWidth(fromViewController.view.frame)/2, -CGRectGetHeight(fromViewController.view.frame)/2, CGRectGetWidth(toViewController.view.frame)*2, CGRectGetHeight(toViewController.view.frame)*2)

        let quadraticStartFrame = CGRect(x: startFrame.origin.x - (startFrame.height - startFrame.width)/2, y: startFrame.origin.y, width: startFrame.height, height: startFrame.height)

        containerView!.insertSubview(toViewController.view, atIndex: 0)
        containerView!.addSubview(imageViewSnapshot)


        // UIViewController circle shrink animation
        let bigCirclePath = UIBezierPath(ovalInRect: quadraticStartFrame)

        let smallCirclePath = UIBezierPath(ovalInRect: imageViewSnapshot.frame)
        let maskLayer = CAShapeLayer()
        maskLayer.frame = toViewController.view.frame
        maskLayer.path = bigCirclePath.CGPath//maskPath.CGPath
        fromViewController.view.layer.mask = maskLayer

        let pathAnimation = CABasicAnimation(keyPath: "path")
        pathAnimation.delegate = self
        pathAnimation.fromValue = bigCirclePath.CGPath
        pathAnimation.toValue = smallCirclePath.CGPath
        pathAnimation.duration = transitionDuration(transitionContext)
        maskLayer.path = smallCirclePath.CGPath
        maskLayer.addAnimation(pathAnimation, forKey: "pathAnimation")

        //        pathAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)

        imageViewSnapshot.frame = quadraticStartFrame

        // Make imageView visible with animation
        let showImageViewAnimation =  {
            imageViewSnapshot.alpha = 1.0
        }
        let showImageViewDelay = 0.3
        UIView.animateWithDuration(transitionDuration(transitionContext) - showImageViewDelay , delay: showImageViewDelay, options: UIViewAnimationOptions.CurveLinear, animations: showImageViewAnimation) { (completed) -> Void in
        }

        // Shrink the imageView to the original size
        let scaleImageViewAnimation = {
            imageViewSnapshot.frame = imageViewSnapshotOriginalFrame
        }
        UIView.animateWithDuration(transitionDuration(transitionContext), delay: 0.0, options: UIViewAnimationOptions.CurveLinear, animations: scaleImageViewAnimation) { (completed) -> Void in
            // After the complete animations have endet

            // Hide ImageView after it is completely resized. Added some animation delay to not abruptly change the contactImage
            if self.hideDelayed {
                let hideImageViewAnimation =  {
                    imageViewSnapshot.alpha = 0.0
                }
                UIView.animateWithDuration(0.2 , delay: 0.2, options: UIViewAnimationOptions.CurveLinear, animations: hideImageViewAnimation) { (completed) -> Void in
                    imageViewSnapshot.removeFromSuperview()
                }
            }
            else {
                imageViewSnapshot.removeFromSuperview()
            }
            toViewController.view.layer.mask = nil
        }
    }

    override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
        if let transitionContext = self.transitionContext {
            transitionContext.completeTransition(!transitionContext.transitionWasCancelled())
        }
    }

    // MARK: UIViewControllerTransitioningDelegate protocol methods

    // return the animataor when presenting a viewcontroller
    func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return self
    }

    // return the animator used when dismissing from a viewcontroller
    func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return self
    }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

UIViewControllerAnimatedTransitioning:旋转更改后黑屏片段 的相关文章

  • 如何在 Swift 中枚举 OptionSetType?

    我在 Swift 中有一个自定义的 OptionSetType 结构 如何枚举一个实例的所有值 这是我的选项集类型 struct WeekdaySet OptionSetType let rawValue UInt8 init rawVal
  • 记录使用 OpenAL 播放的样本

    我在 iOS 上使用 OpenAL 同时播放 9 个循环 为了使循环 100 同步 它们开始在不同的线程上运行 有关使用 OpenAL 记录正在播放的内容的任何指示 教程 如果我使用不同的线程 我会遇到录制问题吗 iOS 上的 OpenAL
  • 从 Google/Facebook 帐户重新验证用户身份

    因此 我需要创建一个 REST API 来为 IOS 应用程序提供功能 我们允许用户仅使用普通帐户或使用脸书 谷歌登录 我最近一直在阅读 OAuth 我想我了解在我的情况下如何使用 OAuth 的过程 当用户使用脸书 谷歌登录 在我的应用程
  • 在 Alamofire 中快速发送 GET 请求中的 json 对象

    我正在尝试执行一个绑定了 json 对象的 GET 请求 这就是我生成 JSON 对象的方式 let jsonObject String AnyObject ean code type match value 16743799 然后我执行了
  • 无法将类型“(User?, Error?) -> ()”的值转换为预期参数类型“AuthDataResultCallback?”

    当我更新 firebase pod 时出现此错误 无法将类型 User Error gt 的值转换为预期参数类型 AuthDataResultCallback 又名 可选 gt static func signUp username Str
  • iOS 显示 UIImage 全屏并启用缩放(捏合和双击)

    我有一个UIImage从相机捕获UIImagePickerController 现在 在用户单击它之后 我希望它显示全屏 并且能够使用捏合手势进行放大和缩小 还可以使用双击手势来放大特定区域 换句话说 我想模拟ios默认图像浏览器的功能 我
  • 可达性更改通知应仅调用一次

    我在我的 swift 项目中使用了 Reachability 我在 AppDelegate 中有以下代码 NSNotificationCenter defaultCenter addObserver self selector reacha
  • 快速将数据从 tableviewcontroller 传递到另一个 tableviewcontroller

    我有一个正在创建的表单 该表单填充有用户输入的文本字段 回答完所有问题后 会弹出一个保存按钮 我在使此表视图控制器将数据传递到新的表视图控制器时遇到问题 我被困住了 不知道该怎么做 import UIKit class TableViewC
  • iOS 新手。预期的表达错误?

    这看起来很不寻常 因为该方法与我的 showAnswer 方法完全相同 所以我想我应该在这里问 import QuizViewController h interface QuizViewController end implementat
  • just_audio 无法在 ios flutter 上工作未处理的异常:(-11800)操作无法完成

    我正在尝试从它自己的存储库运行 just audio 示例项目https github com ryanheise just audio tree master just audio example https github com rya
  • 让约束在尺寸类别中发挥作用

    所以 我正在 Xcode 6 beta 中尝试尺寸类 我对图像设置了一些限制 使其根据 iPhone 纵向和横向对应的尺寸类别处于不同的位置 这些限制在下图中可见 正如您所看到的 当我处于紧凑 紧凑状态时 一些约束被 安装 而其他约束则没有
  • 如何使用 HTTP 标头发送非英语 unicode 字符串?

    我是 HTTP 相关问题的新手 我的问题是在 iOS 开发中 我想使用 HTTP 标头发送一个字符串 所以我使用 httpRequest setValue nonEnglishString forHTTPHeaderField custom
  • Swift 枚举内部是如何实现的?

    我最近问了一个问题C 中的通用枚举 结构 https stackoverflow com questions 68383728 if a uintptr t can be used to store both pointers and nu
  • 将多个数组合并为一个数组

    如何将多个数组合并为一个二维数组 鉴于我有以下输入 var arr1 1 2 3 var arr2 a b c var arr3 aa bb cc 我需要这样的输出 1 a aa 2 b bb 1 c cc 我认为你想要的是将三个数组组合成
  • 处理核心数据中的重复条目

    我有一个允许用户保存收藏夹的应用程序 我正在使用 Core Data 将收藏夹存储为托管对象 我已经编写了一些代码来防止存储重复项的可能性 但我想知道是否有更好的方法来做到这一点 每个收藏夹对象都有一个唯一的 ID 字段 在下面的代码中 我
  • 连接到 Apple Music

    所以我尝试使用 React Native 应用程序从 iOS 设备连接到 Apple Music 有一个 API 可以执行相同的操作 但我需要从 storekit 框架调用一个函数 提出个性化请求 苹果音乐API https develop
  • 为什么 iOS 5.0 不喜欢纯窗口应用程序?为什么它要求使用视图控制器?

    我有一个使用 Xcode 4 0 的 基于窗口的应用程序 模板创建的 iOS 应用程序 当时运行良好 并且使用的是 iOS 4 3 SDK 这是一个简单地将按钮 标签等直接放置到窗口上的应用程序 没有视图控制器 什么都没有 但现在我已经升级
  • 子视图控制器旋转方法未被调用

    Summary 我试图将子视图控制器添加到父视图控制器 并让父视图控制器通知子视图控制器旋转事件 但是 旋转消息不会转发到子视图控制器 这是默认行为 为什么这种默认行为没有发生 环境 iOS 7 XCode 5 OSX 10 9 Detai
  • 配置 2 在按钮 swiftUI 中发出警报消息

    我要学习 swift 和 swiftUI 我申请按类别整理笔记 如果需要的话 你可以在我的 GitHub 中找到我的项目 https github com yoan8306 List Notes https github com yoan8
  • 使用 NSOutlineView 作为文件系统目录浏览器的 Swift 代码

    我已经在这段 Swift 代码上苦苦挣扎了一段时间 但没有发现问题 代码 下面应该提供文件目录作为 NSOutlineView 的数据源 GUI 非常简单 只是一个带有 NSOutlineView 和 OutlineViewControll

随机推荐

  • 使用模数按字母顺序对列表进行排序

    我在获取元素列表并按字母顺序对它们进行排序方面没有任何问题 但我很难理解如何使用模数来做到这一点 更新 这是按我的方式工作的代码 但是 我更喜欢下面提供的答案的可重用性 因此接受了该答案
  • 如何在 __init__ 中使用await设置类属性

    我如何定义一个类await在构造函数或类体中 例如我想要的 import asyncio some code class Foo object async def init self settings self settings setti
  • Supabase 客户端权限被拒绝,模式为 public

    每当我尝试使用 supabase supabase js 查询数据库时 都会收到错误 error hint null details null code 42501 message permission denied for schema
  • HSQL - 识别打开连接的数量

    我正在使用嵌入式 HSQL 数据库服务器 有什么方法可以识别活动打开连接的数量吗 Yes SELECT COUNT FROM INFORMATION SCHEMA SYSTEM SESSIONS
  • 如何使用sunspot_rails gem 搜索相关文章

    我有一个迷你博客应用程序 我希望用户查看与他们在文章显示页面中阅读的内容相关的文章 没有 sunspot rails gem 我会做这样的事情 在我的模型中 def self related search query join AND fi
  • PNG 透明度问题 - 带有黑色阴影的褪色图像 - IE 中的边框

    我使用图像旋转器在主页上显示一些图像 所有图像均为 PNG 格式 问题出在 IE 7 8 中 图像旁边有黑色阴影 我花了几个小时来解决这个问题 但仍然不知道问题出在哪里以及如何删除它 没有人有类似的问题和提示吗 如何解决 尝试使用 img
  • 在 NodeJS 中将子进程的输出保存在父进程的变量中

    我想在 NodeJS 中启动一个子进程并将其输出保存到一个变量中 以下代码将其提供给标准输出 require child process execSync echo Hello World stdio inherit 我的想法与此代码类似
  • XAMPP为MariaDB设置root用户密码

    如何在 Ubuntu Kubuntu 16 04 上的 XAMPP 中设置 MariaDB 的 root 用户密码 默认情况下 root 用户没有设置密码 我正在使用 XAMPP 7 1 11 我在 Windows 和 Linux 上都成功
  • Pig Udf 显示结果

    我是 Pig 的新手 我用 Java 编写了一个 udf 并且包含了一个 System out println 其中的声明 我必须知道在 Pig 中运行时该语句在哪里打印 假设你的UDF 扩展了 EvalFunc 您可以使用从返回的 Log
  • 如何在 Spring 中禁用使用 @Component 注释创建 bean?

    我的项目中有一些用于重构逻辑的通用接口 它看起来大约是这样的 public interface RefactorAwareEntryPoint default boolean doRefactor if EventLogService wa
  • 如何设置Firestore安全规则? Resource.data:空值错误

    我需要一些帮助来使我的 Firestore 安全规则发挥作用 这些是我的 Firestore 规则 service cloud firestore match databases database documents match order
  • 从数组中删除空白元素

    当我从 ruby on Rails 表单中保存多个选择时 它似乎在前面添加了一个空白元素 我该如何删除它 该字段为 selected player utf8 gt authenticity token gt H8W7qPBezubyeU0a
  • 以编程方式将文本颜色设置为主要 Android 文本视图

    如何设置我的文本颜色TextView to android textColorPrimary以编程方式 我已经尝试了下面的代码 但它将 textColorPrimary 和 textColorPrimary Inverse 的文本颜色始终设
  • 从实时 tcpdump 捕获中提取唯一的 IP

    我使用以下命令从实时 tcpdump 捕获中输出 IP sudo tcpdump nn q ip l awk print 3 fflush stdout gt gt ips txt 我得到以下输出 192 168 0 100 50771 1
  • Rails content_for 和yield 之间有什么区别?

    例如 content for stuff vs yield stuff 我知道它们的实现略有不同 但是有任何真正的功能差异吗 是否有普遍接受的最佳实践 yield是您指定内容区域在布局中的位置的方式 你可能有这样的事情 div h1 Thi
  • AVAssetExportSession 无法导出从 iCloud 下载的视频

    我正在尝试创建从用户相册中选择的视频的缩小版本 输出的最大尺寸为 720p 因此 在检索视频时 我使用 mediumQualityFormat as the deliveryMode 如果用户设备中不存在原始视频或其中等质量版本 这会导致
  • 为什么 dataclasses.astuple 返回类属性的深层副本?

    在下面的代码中astuple函数正在执行数据类的类属性的深层复制 为什么它不能产生与函数相同的结果my tuple import copy import dataclasses dataclasses dataclass class Dem
  • pickle.PicklingError:无法腌制未打开读取的文件

    我在 Dataproc 上运行 PySpark 作业时收到此错误 可能是什么原因 这是错误的堆栈跟踪 File usr lib python2 7 pickle py line 331 in save self save reduce ob
  • SQL 约束以防止根据列的先前值更新列

    是否可以使用检查约束 或其他一些技术 来防止在更新记录时设置与其先前值相矛盾的值 一个例子是 NULL 时间戳 表明发生了某些事情 例如 file exported 一旦文件被导出并且具有非 NULL 值 就不应再将其设置为 NULL 另一
  • UIViewControllerAnimatedTransitioning:旋转更改后黑屏片段

    我已经创建了一个视图控制器转换 只要我不更改设备方向 一切都正常 图 1 显示了应有的屏幕 然后我切换到下一个视图控制器 在其中更改方向 现在我回到第一个视图控制器并再次切换方向 然后我得到的结果如图 2 所示 出现黑色边框 请不要介意屏幕