我想检测 facebook 视频和 instrgram 视频 url 的视频 url,但 WKWebView 给出了 youtube 视频 url 我已经使用了 WKWebView 导航委托,它没有给出视频 url
webView!.addObserver(self, forKeyPath: "URL", options: .new, context: nil)
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if let key = change?[NSKeyValueChangeKey.newKey] {
print("observeValue \(key)") // url value
}
}
Run Code Online (Sandbox Code Playgroud) Apple 的Implementing Modern Collection Views有一个UICollectionViewCell在Modern Collection Views/Cell Configurations. 它演示了如何将自定义视图添加到UICollectionViewCell.
我想要的是它是一个 UITextField 单元格。所以我添加了一个 UITextField ,代码是:
class CustomConfigurationCell: UICollectionViewListCell {
// Trying to gain access to UITextField
// But contentView is not a CustomContentView
var textField: UITextField? {
guard let contentView = contentView as? CustomContentView else {
return nil
}
return contentView.textField
}
override func updateConfiguration(using state: UICellConfigurationState) {
var content = CustomContentConfiguration().updated(for: state)
content.name = name
contentConfiguration = content
}
}
struct CustomContentConfiguration: …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Apple 在 iOS 14 中引入的优惠代码功能。虽然它大部分有效,但我们收到了用户的问题报告,称他们实际上无法兑换优惠。
从文档中:
选择您的报价的客户资格。您可以选择新用户、活动用户或过期用户的任意组合。
- 新用户:从未订阅过群内任何订阅产品的用户。
- 活跃:当前订阅组内产品的用户。
- 已过期:之前订阅过群组内产品但订阅已过期的用户。
我们的订阅组有以下计划(仅1级):
我们已为 12 个月计划创建了优惠代码。
因此,根据文档,当前订阅 1m、3m、6m 计划的用户应该能够使用此优惠进行交叉升级。
但实际尝试执行此操作的用户会收到错误:
您当前的订阅无法兑换此优惠。
我检查过,在同一个订阅组中,如果不使用该优惠,用户可以毫无问题地进行交叉升级。我有什么想法吗?
由于某种原因,在我选择一个值后,我的 SwiftUI 表单中的选择器会变成灰色。
我的代码:
Form {
Section {
TextField("title", text: $title)
Picker(selection: $category, label: Text("category")) {
ForEach(0..<categories.count) { index in
Text(categories[index]).tag(index)
}
}
}
}
Run Code Online (Sandbox Code Playgroud)

我有一个带有 a 的项目SceneDelegate,并且我在 SwiftUI 视图中使用以下代码:
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification)) { _ in
print("Did become active...")
}
Run Code Online (Sandbox Code Playgroud)
它在 iOS 13 中被调用,但当我在 iOS 14 上运行它时,它没有运行。
更多详细信息:didBecomeActiveNotification当我将应用程序放入后台后将其置于前台时调用,但当应用程序第一次打开时则不会调用。但在 iOS 13 中,它会在第一次打开调用时执行此操作。
我将 Xcode 从 12.2 更新到 12.3,问题仍然存在。didBecomeActiveNotification有人可以检查使用 iOS 14 打开应用程序时是否接到电话吗?
知道如何进行这项工作吗?
附言。要在 Xcode 12 上使用 SceneDelegate 创建项目AppName.app,应删除该文件,然后使用样板代码创建文件并编辑SceneDelegate.swift“应用程序场景清单”键以使其使用 SceneDelegate。AppDelegate.swiftinfo.plist
我正在使用 SwiftUI 2.0,我正在尝试实现 firebase 推送通知。在新的 SwiftUI 应用程序结构中,没有 AppDelegate 和 SceneDelegate,因此我创建了 AppDelegate 类。我设法接收通知,但无法在单击通知时转到特定视图。这是我的代码:
@main
struct swiftUiApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
Run Code Online (Sandbox Code Playgroud)
和 AppDelegate 扩展:
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
let orders = Orders()
let userInfo = response.notification.request.content.userInfo
// Print message ID.
if let messageID = userInfo[gcmMessageIDKey] {
print("Message ID: \(messageID)")
}
if(userInfo["gcm.notification.type"] != nil){
if(userInfo["gcm.notification.type"] as! String == "order"){
//here I …Run Code Online (Sandbox Code Playgroud) 我已经为我的 IOS 应用程序完成了质量扫描分析。我收到以下警告:
The binary has Runpath Search Path (@rpath) set. In certain cases an attacker can abuse this feature to run arbitrary executable for code execution and privilege escalation. Remove the compiler option -rpath to remove @rpath.
Run Code Online (Sandbox Code Playgroud)
我搜索@rpath并在我的代码pod-framework.sh和下面的代码中找到了:
# Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
local swift_runtime_libs
swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u) …Run Code Online (Sandbox Code Playgroud) 目前,我已经picker包含在 aSection中Form,我想要达到的目标是将所选值picker与 iOS 13 和 14 中的前导对齐,我已经尝试了许多解决方案,例如labelsHidden()但没有结果,请找到在 iOS 14 上生成以下屏幕截图的代码示例,任何帮助将不胜感激
struct ContentView: View {
@State private var selectedStrength = "Mild"
let strengths = ["Mild", "Medium", "Mature"]
var body: some View {
NavigationView {
Form {
Section {
Picker("", selection: $selectedStrength) {
ForEach(strengths, id: \.self) {
Text($0)
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 我为 UIButtons 以及选项卡栏中设置了系统图像。这适用于 iOS 14,但在 iOS 13 上图像丢失。
iOS 13 上系统映像丢失的原因可能是什么?
细节:
我在故事板中有一个按钮,其图像属性设置为“square.and.arrow.up”。(参见下面的屏幕截图)该图像出现在 iOS 14 上,但不在 iOS 13 上(参见下面的屏幕截图。模拟器重叠)
选项卡栏项目也会发生类似的行为。(见下面的其他截图)
Xcode 为 12.5、MacOS 11.2.3、iOS 模拟器 13.6 和 14.5。这种情况也发生在设备上,而不仅仅是模拟器中。
SF Symbols App 声称该图标自 iOS 13+ 起可用。
如有任何帮助,我们将不胜感激:-)
我们的 iOS/iPadOS 应用程序遇到了极其奇怪的崩溃。
\n我们最新版本中的一些重大变化:
\n好吧,这是奇怪的部分:我们的应用程序对于直接从 iOS 14 和 15 上的 App Store 或 TestFlight 下载并安装应用程序的用户来说运行良好。
\n然而,对于 iOS 14 用户来说,该应用程序在启动时会崩溃,这些用户通过 MDM 从 App Store(公开或私人发布,无关紧要)将应用程序推送到手机,并从一个对话框中安装它,例如“AirWatch 即将发布”。从 App Store 安装 REDACTED。您的 iTunes 帐户不会因该应用程序而付费。”
\n那么,自己安装后启动应用程序与 MDM 安装后启动应用程序\xe2\x80\x94 之间有什么区别,在这两种情况下,应用程序都源自 App Store?
\n这是一个崩溃日志示例:
\n{"app_name":"REDACTED","timestamp":"REDACTED","app_version":"REDACTED","slice_uuid":"REDACTED","adam_id":REDACTED,"build_version":"REDACTED","platform":0,"bundleID":"com.REDACTED.REDACTEDapp","share_with_app_devs":0,"is_first_party":0,"bug_type":"109","os_version":"iPhone OS 14.6 (18F72)","incident_id":"REDACTED","name":"REDACTED"}\nIncident Identifier: REDACTED\nCrashReporter Key: REDACTED\nHardware Model: iPhone11,8\nProcess: REDACTED [1561]\nPath: …Run Code Online (Sandbox Code Playgroud)