Questions tagged «swift»

Swift是Apple Inc.针对其平台和Linux开发的一种安全,快速且具有表现力的通用编程语言。Swift是开源的。仅将标记用于有关语言功能或在Swift中需要代码的问题。将标签[ios],[ipados],[macos],[watch-os],[tvos],[cocoa-touch]和[cocoa]用于有关平台或框架的(语言不可知)问题。

2
在附件上滚动时,iOS 13.1 UITextView委托方法应当调用InterInteract
我正在使用UITextView委托方法来执行一些自定义工作,例如当用户点击URL或附件时打开应用内浏览器: func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool 在iOS 13中,即使用户只是在URL上滚动(这是不期望的),也会调用此委托方法。此行为也适用于图像附件。 现在通过交互调用该dele方法。 * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 6.1 7.1 * frame #0: 0x0000000104a54c5c ProjectS1`PostListViewController.textView(textView=0x00000001090a4600, URL=Foundation.URL @ 0x000000016b5d1200, characterRange=location=161, length=9, interaction=invokeDefaultAction, self=0x0000000109b03990) at PostListViewController.swift:610:9 frame #1: 0x0000000104a54d70 ProjectS1`@objc PostListViewController.textView(_:shouldInteractWith:in:interaction:) at …

5
使用催化剂移植到Mac时排除Pod
由于Catalyst,最终可以将应用程序移植到macOS了,问题是,许多Pod不支持AppKit。最常见的一种是Crashlytics / Firebase。 In [...]/Pods/Crashlytics/iOS/Crashlytics.framework/Crashlytics(CLSInternalReport.o), building for Mac Catalyst, but linking in object file built for iOS Simulator, file '[...]/Pods/Crashlytics/iOS/Crashlytics.framework/Crashlytics' for architecture x86_64 由于这是一个最近的话题,我找不到有关如何从macOS的构建中删除pod的文档,但是却保留了iOS和iPadO S的文档。 可以在代码中使用: #if !targetEnvironment(macCatalyst) // Code to exclude for your macOS app #endif 但是问题的一部分,另一部分是仅针对iOS链接容器... 如果该库对于macOS而言不是至关重要的,但在iOS上仍然需要,那么最简单/最佳的做法是什么?

2
使用AVPlayer会返回“非多路径连接”错误
我正在使用AVKit播放youtube URL。 我在按钮动作中包含以下代码: @IBAction func trailerButtonAction(_ sender: Any) { guard let youtubeUrl = youtubeURL else { return } let player = AVPlayer(url: youtubeUrl) let playerViewController = AVPlayerViewController() playerViewController.player = player present(playerViewController, animated: true) { player.play() } } 该URL有效,但是当我按下按钮时,视频不会停止加载,并且在Debug区域收到此消息: nw_endpoint_flow_copy_multipath_subflow_counts在非多路径连接上调用 编辑: 我发现AVPlayer不支持youtube URL

4
Swift 5.1错误:[插件] AddInstanceForFactory:没有为ID <CFUUID注册的工厂
应用程序崩溃并显示以下错误消息 2019-10-12 20:01:34.332334-0700 Awesome App[26368:3535170] [plugin] AddInstanceForFactory: No factory registered for id &lt;CFUUID 0x600002903280&gt; F8BB1C28-BAE8-11D6-9C31-00039315CD46 崩溃时的断点似乎与AVAudioPlayer有关 let path = Bundle.main.path(forResource: "menu_background.mp3", ofType:nil)! audioPlayer = try AwesomeAudioPlayer(contentsOf: URL(fileURLWithPath: path)) ---&gt; breakpoint
14 swift  swift5  swift5.1 

2
Xcode 11.2中的IconRenderer警告
我刚刚创建了一个新的iOS Single View App,然后尝试构建并运行它。我收到以下警告: [Renderer] IconRenderer: HorizontalStretchPadding (18.000000, 18.000000) is larger than the image size (34.000000, 54.000000). Image will now use the center column of pixels to stretch. 此警告不断显示多次。
13 ios  swift  xcode  xcode11.2 

2
从iOS应用检测用户的watchOS版本
我有一个iOS应用程序,我在iOS应用程序中有一些与手表相关的设置。我只想显示给用户显示与我的应用程序兼容的Apple Watch。 在WatchConnectivity中,我可以查询WCSession的isPaired属性以查看用户是否有手表,但是我不知道如何确定watchOS版本(要使用我的应用,该版本必须大于5.0)。 有没有办法从iOS应用程序确定watchOS版本?

2
Xcode 11重新编译太多
即使我只是更改局部私有变量,或更改局部范围(有时甚至是局部私有函数范围)中常量的值,Xcode 11也会重新编译(几乎?)我的整个项目。我有时可以通过快速构建获得2或3个更改,但是很快它决定再次重新编译所有内容(这需要很长时间)。 任何想法可能会发生什么?Xcode无法确定更改了什么,为什么还要重新编译很多其他内容(甚至其他模块)。 任何建议都非常感谢,谢谢!


4
Swift编译器错误:枚举案例有一个元组作为关联值,但是这里有几种模式
在Xcode 11.4 beta 3中构建一个项目,我在枚举中遇到了这个Swift Compiler错误: 枚举案例有一个元组作为关联值,但是这里有几种模式,隐式地将模式组合起来,然后尝试匹配 源代码: switch result { case .error(let err): // case .value(let staff, let locations): // &lt;-- error on this line // } Result是一个通用的枚举与相关联的值.error和.value。在这种情况下,关联的值为tupple。 public enum Result&lt;T&gt; { case value(T) case error(Error) } 不要回想起以前曾遇到过此错误,并且搜索该错误不会产生任何结果。有任何想法吗?
12 swift 

3
Xcode在上传时停留在“将包上传到App Store”阶段
我尝试将应用程序上传到Test Flight。该应用程序已成功验证。但是,分发时,Xcode停留在“将包上传到App Store”阶段。我已经等了2个小时,什么都没有改变。我正在使用Xcode 11.1。有没有解决这个问题的办法。提前致谢。
12 ios  swift  xcode 

1
iOS Swift-如何获取本地和远程视频的长宽比?
场景:我正在应用程序内部构建WebRTC视图。视频容器的高度始终为160。 在容器的中央应显示最大高度为160的远程视频,宽度应按视频的长宽比进行缩放。宽度也不能大于视图宽度,在这种情况下,宽度将等于视图宽度,并且高度应适合纵横比。 在右上角应显示前摄像头的本地视频,最大宽度为100,高度应调整为尊重本地视频的长宽比 到目前为止,我的代码: func createPeerConnection () { // some other code self.localStream = self.factory.mediaStream(withStreamId: "stream") let videoSource = self.factory.videoSource() let devices = RTCCameraVideoCapturer.captureDevices() if let camera = devices.last, let format = RTCCameraVideoCapturer.supportedFormats(for: camera).last, let fps = format.videoSupportedFrameRateRanges.first?.maxFrameRate { let intFps = Int(fps) self.capturer = RTCCameraVideoCapturer(delegate: videoSource) self.capturer?.startCapture(with: camera, format: …
12 ios  swift  swift5 

2
无法完成将dSYM提交到崩溃解决方案的结构到Firebase的迁移时
我在Mac OS 10.14.1中使用xcode11 我使用以下文档实现了从Fabric到Firebase的迁移。 https://medium.com/@niamhpower/the-great-migration-moving-from-fabric-to-firebase-as-an-ios-developer-7b61a8b40008 我生成了用于测试崩溃的代码,但是该崩溃报告无法出现在firebase crashlytics控制台中。 https://firebase.google.com/docs/crashlytics/force-a-crash?platform=ios 我还在Xcode构建阶段中添加了以下运行脚本 “ $ {PODS_ROOT} / Fabric / upload-symbols” -gsp“ $ {PROJECT_DIR} /GoogleService-Info.plist” -p ios“ $ {DWARF_DSYM_FOLDER_PATH} / $ {DWARF_DSYM_FILE_NAME}” 但这将在我运行应用程序时返回以下错误。 31错误:无法在/Users/macmini1/Library/Developer/Xcode/DerivedData/app_name-dnzsvdsxebmfqjbjecjlyhdzwags/Build/Products/Debug-iphonesimulator/app_name.app.dSYM中完成dSYM的提交:错误Domain = com.crashlytics。 -domain.process-dsym代码= 3“文件(在(null)处不再存在”)UserInfo = {NSLocalizedFailureReason =文件在(null)处不再存在}} [0m命令PhaseScriptExecution失败,退出代码为非零 您能帮我解决这个问题吗


3
导航栏中的从大标题到小标题的切换并不流畅iOS 13
我的UINavigationController默认值为navigationBar.prefersLargeTitles = true。 我将其切换为false当我push 进入新场景时DetailsViewController,通过将其更改为来调用它()viewWillDisappear。 override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) navigationController?.navigationBar.prefersLargeTitles = false } 现在DetailsViewController我正在使用willMove(to parent:)。 override func willMove(toParent parent: UIViewController?) { navigationController?.navigationBar.prefersLargeTitles = true } 过渡回大标题。 考虑到iOS 12是正确的行为,请观察所附的快照,了解iOS 13的运行方式和iOS 12的运行方式。 iOS 13: iOS 12:

5
新的iOS 13模态演示:演示控制器不会向下移动
在iOS 13中以模态方式呈现UIViewControllers时,我的行为很怪异。我在iOS 13上所见过的新呈现方式如下所示: 呈现视图控制器出现在呈现视图控制器的后面。它也向下移动以模仿“堆栈” 同时,当通过我的应用程序展示视图控制器时,我不断得到这种效果: 呈现新的视图控制器时,呈现的视图控制器完全不动 我使用以下代码介绍此视图控制器: let controller = storyboard?.instantiateViewController(withIdentifier: "tutorial") as! TutorialController controller.modalPresentationStyle = .pageSheet controller.modalTransitionStyle = .coverVertical present(controller, animated: true, completion: nil) 这是我的问题: 我想知道为什么会这样,是否有办法以普通的iOS 13样式呈现视图控制器(呈现的视图控制器向后移动)。 提前致谢!

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.