AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / coding / 问题

问题[ios](coding)

Martin Hope
GarySabo
Asked: 2023-09-27 00:01:53 +0800 CST

Swift Charts:如何绘制具有独立于数据的固定梯度的折线图?

  • 6

与这个问题密切相关的是,线性梯度代码运行良好,但它总是与其数据相关联,因此例如下面的代码,如果您有一系列从 70 到 110 的心率,则较低的心率始终为灰色,较高的心率始终为灰色紫色,但 90 到 195 的数组也是如此。如何映射停靠点以使颜色与心率区域相对应?换句话说,心率从 70-110 只会显示蓝色到橙色?

 Chart {
            ForEach(smoothHeartRatesEMA(customHeartRates, decayFactor: 0.3)) { heartRate in
                LineMark(
                    x: .value("Sample Time", heartRate.startDate, unit: .nanosecond), //changed these to .nanosecond to fix Nike Run Club bug (some how Nike Run Club gets more frequent HR samples than other apps?)
                    y: .value("Heart Rate", heartRate.doubleValue)
                )
                .lineStyle(StrokeStyle(lineWidth: 3.0))
                .foregroundStyle(
                    .linearGradient(
                        stops: [
                            .init(color: Color.gray, location: 0.0),
                            .init(color:  TrackerConstants.AppleFitnessBlue, location: 0.16),
                            .init(color: TrackerConstants.AppleFitnessYellow, location: 0.33),
                            .init(color: TrackerConstants.AppleFitnessOrange, location: 0.5),
                            .init(color: TrackerConstants.AppleFitnessRed, location: 0.66),
                            .init(color: TrackerConstants.AppleFitnessPurple, location: 1.0) //how do I get these to allign with a range of e.g. 170-210.  I.e. if no heart rate is above 170bpm, the line is never purple?
                        ],
                        startPoint: .bottom,
                        endPoint: .top)
                         )
            }
        }
        .chartYScale(domain: 50...210)
ios
  • 1 个回答
  • 22 Views
Martin Hope
alionthego
Asked: 2023-09-25 06:28:00 +0800 CST

将应用程序导出到 IPA 或 xarchive 以供第三方使用时,是否需要更改应用程序组标识符?

  • 5

我正在为第三方创建一个 ipa 或 xarchive 文件,该文件将在他们的公司内部分发我的应用程序。

到目前为止,他们收到以下错误消息:

error:container_create_or_lookup_app_group_path_by_app_group_identifier: client is not entitled

他们正在使用自己的反向域为应用程序组创建自己的捆绑包 ID。我是否需要更改应用程序中的权利文件或组 ID 以匹配我的构建中的权利文件或组 ID?或者它们应该与我的应用程序组 ID 匹配吗?或者这个问题与此无关?不太确定如何解决这个问题。

ios
  • 1 个回答
  • 14 Views
Martin Hope
David Kroukamp
Asked: 2023-09-24 23:17:03 +0800 CST

Swift 后台 downloadTask 不调用 willPerformHTTPRedirection

  • 5

我在使用后台 urlsession 时遇到问题,但我的willPerformHTTPRedirection没有被调用:

private class BackgroundCachingDelegate: NSObject, URLSessionDelegate, URLSessionTaskDelegate, URLSessionDownloadDelegate
{
    func urlSession(_ session: URLSession, task: URLSessionTask, willPerformHTTPRedirection response: HTTPURLResponse, newRequest request: URLRequest) async -> URLRequest?
    {
        //... Never gets called
    }
}

我这样称呼它:

private func createNewBackgroundSession()
{
    let backgroundCachingConfiguration = URLSessionConfiguration.background(withIdentifier: OfflineCacheService.entityBackgroundSessionIdentifier)
    backgroundCachingConfiguration.requestCachePolicy = .reloadIgnoringLocalCacheData
    let backgroundCachingDelegate = BackgroundCachingDelegate(/*params*/)
    self.backgroundCachingSession = URLSession(configuration: backgroundCachingConfiguration, delegate: backgroundCachingDelegate, delegateQueue: nil)
}
    
private func startRequest(url: URL)
{
    if self.backgroundCachingSession == nil
    {
        self.createNewBackgroundSession()
    }
        
    var request = self.uiViewController.getURLRequest(method: "GET", url: url)
    request.cachePolicy = .reloadIgnoringCacheData
    self.backgroundCachingSession!.downloadTask(with: request).resume()
}

如果我直接获取重定向的 URL 并尝试使用它,该代码就会起作用。

我还确定服务器正在执行重定向: 在此输入图像描述

有任何想法吗?

更新

也许还要提一下,我确实得到了 0 字节的响应,并将重定向的 url 作为响应 url。我可以根据上面的情况有一个边缘情况并调用新的重定向网址,但如果不是这样,我更喜欢正确的方法。

ios
  • 1 个回答
  • 15 Views
Martin Hope
Guard P
Asked: 2023-09-24 21:32:49 +0800 CST

Cocoapods (AFNetworking) 归档项目时出现问题

  • 4

我正在尝试构建一个遗留的 Obj-C 项目,它取得了大约 80% 的进度,但失败并出现以下错误。我尝试重新安装 pod,清理派生数据,重新启动 Xcode/计算机。

`mkdir -p /Users/myusername/Library/Developer/Xcode/DerivedData/MyApp-cghzlwxuhadyvrehqungfijxixti/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphoneos/MyApp.app/Frameworks

Symlinked...

rsync --delete -av --filter P .*.?????? --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" 

"../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/AFNetworking.framework" "/Users/myusername/Library/Developer/Xcode/DerivedData/MyApp-cghzlwxuhadyvrehqungfijxixti/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app/Frameworks"

building file list ... rsync: link_stat
 "/Users/myusername/myapp_ios/MyApp/../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/AFNetworking.framework" failed: No such file or directory (2)
done

sent 29 bytes  received 20 bytes  98.00 bytes/sec
total size is 0  speedup is 0.00
rsync error: some files could not be transferred (code 23) at /AppleInternal/Library/BuildRoots/97f6331a-ba75-11ed-a4bc-863efbbaf80d/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c(996) [sender=2.6.9]
Command PhaseScriptExecution failed with a nonzero exit code`
ios
  • 1 个回答
  • 24 Views
Martin Hope
isenwald2022
Asked: 2023-09-24 20:34:06 +0800 CST

在委托外观中使用 Swift Actor

  • 5

我正在阅读这个博客,因为我有一个类似的用例:https://kelvas09.github.io/blog/posts/closure-delegate-to-async/

我注意到以下片段:

actor BluetoothLEScanWrapper {

enum BluetoothLEScanError: Error {
    case bluetoothNotAvailable
}

private let bluetoothLEDelegate: BluetoothLEDelegate = BluetoothLEDelegate()
private var activeTask: Task<[BluetoothLEDevice], Error>?

func scan(for seconds: Double = 3.0) async throws -> [BluetoothLEDevice] {

    if let existingTask = activeTask {
        return try await existingTask.value
    }

    let task = Task<[BluetoothLEDevice], Error> {
        guard bluetoothLEDelegate.bluetoothIsOn else {
            activeTask = nil
            throw BluetoothLEScanError.bluetoothNotAvailable
        }

        self.bluetoothLEDelegate.central.scanForPeripherals(withServices: nil)

        try await Task.sleep(nanoseconds: (UInt64(seconds) * 1_000_000_000))

        let devices = bluetoothLEDelegate.foundPeripheral.compactMap { BluetoothLEDevice(peripheral: $0) }

        bluetoothLEDelegate.central.stopScan()
        bluetoothLEDelegate.foundPeripheral = []

        activeTask = nil

        return devices
    }

    activeTask = task

    return try await task.value

}
...

作者特别呼吁注意演员的使用​​。据我了解,这是为了避免重复调用activeTask时的数据竞争scan()。我的理解正确吗?谢谢您的帮助。

ios
  • 1 个回答
  • 34 Views
Martin Hope
Chandan Sayed
Asked: 2023-09-24 19:04:13 +0800 CST

如何在 Next JS 元数据中添加元标记

  • 5

我试图在 Next JS 13.4 中添加元标记,但我不能。我已阅读文档并用谷歌搜索,但找不到解决方案。我正在尝试以 Next JS 方式添加此 HTML 元标记。

<meta name="apple-mobile-web-app-title" content="AppTitle">

我在 Next JS 元数据中尝试的是

export const metadata = {
  title: 'MessageMoment - The real meaning to personal!',
  description: 'MessageMoment - The real meaning to personal!',
  creator: 'Chandan Sayed',
  short_name: 'MessageMoment',
  applicationName: 'MessageMoment',
  siteName: 'MessageMoment',
  appleMobileWebAppTitle: 'MessageMoment'
}

但这不起作用,请帮助我。提前致谢。

ios
  • 1 个回答
  • 25 Views
Martin Hope
NickyP
Asked: 2023-09-22 01:25:32 +0800 CST

尝试运行 iOS 模拟器时找不到 Info.plist 构建文件

  • 5

尝试运行我的 iOS 项目时收到以下错误代码。

无法构建 iOS 应用程序错误(Xcode):找不到构建输入文件:'/Users/nicho/Im_Free/im_free/ios/Pods/Runner/Info.plist'。您是否忘记将此文件声明为脚本阶段或生成它的自定义构建规则的输出?

Flutter 3.14.0-14.0.pre.405 Dart 3.2.0(内部版本 3.2.0-185.0.dev) • DevTools 2.28.0-dev.12 Xcode 13.0

很感谢任何形式的帮助。

我尝试过更新 pod、清理构建文件夹、确保 flutter 是最新的并运行 flutter doctor,但没有出现任何问题。

ios
  • 1 个回答
  • 26 Views
Martin Hope
Kitten's Tech
Asked: 2023-09-18 07:08:37 +0800 CST

致命错误:隐式解包可选值时意外发现 nil

  • 4

我的问题是我的程序构建时没有错误,然后每当我单击按钮时,它都会在代码行上抛出错误“致命错误:隐式展开可选值时意外发现 nil”: SubButton1Outlet.isEnabled = true

我正在尝试使故事板编辑器中设置为禁用的按钮自行启用。我确保 IBOutlet 已连接到故事板中的右侧按钮,但它仍然抛出错误。

override func viewDidLoad() {
        super.viewDidLoad()
        CallMemory()
        SubButton1Outlet.isEnabled = true
    }
    
    @IBAction func SubButton1(_ sender: Any) {
        SubNumber = 1;
    }
    @IBOutlet weak var SubButton1Outlet: UIButton!

这是与问题相关的整个代码部分以及 Xcode 的一些屏幕截图。完整的 GitHub 项目:https://github.com/DarkCat736/SubscriptionManager/

Xcode 模拟器照片

Xcode 代码编辑器

完整的 Xcode 窗口

我的期望:

  • 程序加载
  • SubButton1 变为启用状态
  • var SubNumber被设置为值1
  • 单击 SubButton1 并打开另一个场景

发生了什么:

  • 程序加载
  • SubButton1 变为启用状态
  • SubButton1 被单击
  • 程序抛出错误并停止
ios
  • 1 个回答
  • 31 Views
Martin Hope
BPDev
Asked: 2023-09-07 09:40:08 +0800 CST

如何在@AppStorage中存储字体?

  • 6

我想让用户选择自定义字体。

import SwiftUI

class FontPickerVM: ObservableObject {
    @AppStorage("custom_font") var font: Font? = nil
    // @Published var font: Font? = nil
}

extension Font: RawRepresentable {
    public typealias RawValue = String
    
    
    public init?(rawValue: RawValue) {
        
    }
    
    public var rawValue: RawValue {
        
    }
}

RawRepresentable我该如何实施Font?


我正在使用 aUIFontPickerViewController来选择字体。

import UIKit
import SwiftUI

public struct SUIFontPicker: UIViewControllerRepresentable {
    
    @Environment(\.presentationMode) var presentationMode
    private let onFontPick: (UIFontDescriptor) -> Void
    
    public init(onFontPick: @escaping (UIFontDescriptor) -> Void) {
        self.onFontPick = onFontPick
    }
    
    public func makeUIViewController(context: UIViewControllerRepresentableContext<SUIFontPicker>) -> UIFontPickerViewController {
        let configuration = UIFontPickerViewController.Configuration()
        configuration.includeFaces = true
        configuration.displayUsingSystemFont = false
        
        let vc = UIFontPickerViewController(configuration: configuration)
        vc.delegate = context.coordinator
        return vc
    }
    
    public func makeCoordinator() -> SUIFontPicker.Coordinator {
        return Coordinator(self, onFontPick: self.onFontPick)
    }
    
    public class Coordinator: NSObject, UIFontPickerViewControllerDelegate {
        
        var parent: SUIFontPicker
        private let onFontPick: (UIFontDescriptor) -> Void
        
        
        init(_ parent: SUIFontPicker, onFontPick: @escaping (UIFontDescriptor) -> Void) {
            self.parent = parent
            self.onFontPick = onFontPick
        }
        
        public func fontPickerViewControllerDidPickFont(_ viewController: UIFontPickerViewController) {
            guard let descriptor = viewController.selectedFontDescriptor else { return }
            onFontPick(descriptor)
            parent.presentationMode.wrappedValue.dismiss()
        }
        
        public func fontPickerViewControllerDidCancel(_ viewController: UIFontPickerViewController) {
            parent.presentationMode.wrappedValue.dismiss()
        }
    }
    
    public func updateUIViewController(_ uiViewController: UIFontPickerViewController,
                                       context: UIViewControllerRepresentableContext<SUIFontPicker>) {
        
    }
}

struct FontPicker: View {
    
    @State var isFontPickerPresented = false
    @Environment(\.font) var defaultFont
    
    @StateObject var vm = FontPickerVM()
    
    var body: some View {
        Button {
            isFontPickerPresented = true
            printDetails()
        } label: {
            Text("Select font")
        }
        .sheet(isPresented: $isFontPickerPresented) {
            SUIFontPicker { fontDescriptor in
                let newFont = UIFont(descriptor: fontDescriptor, size: 18)
                vm.font = Font(newFont as CTFont)
                printDetails()
            }
        }
        .font(vm.font)
    }
    
    func printDetails(){
        print("default font:", defaultFont ?? "")
        print("custom font:", vm.font ?? "")
    }
}



struct FontPicker_Previews: PreviewProvider {
    static var previews: some View {
        Form {
            FontPicker()
            FontPicker()
        }
    }
}

我必须指定大小UIFont(descriptor: fontDescriptor, size: 18),但我只想更改字体系列。

ios
  • 1 个回答
  • 15 Views
Martin Hope
Shawn Frank
Asked: 2023-09-07 06:21:45 +0800 CST

UIButton 框架大小不会更新以支持设置中增加的字体大小

  • 5

我有一个基本的 UIButton ,具有以下约束:

UIButton自动布局约束动态文本字体大小

我有一些基本的尾随和顶部约束,并且 >= 宽度和高度约束设置为 48,因为我希望 48 作为按钮的最小宽度和高度。

我的目标是当用户从设置中更改字体大小时,按钮中的文本会变大。

按钮中的文本大小似乎在增加,但是,框架似乎没有更新以适应这种增加。

在此输入图像描述

这就是我的意思从控制面板设置字体大小 动态文本字体大小控制面板 iOS Swift

但是,如果我退出应用程序并再次启动它,框架大小会正确计算,并且从控制面板更改文本大小似乎会使按钮中的字体大小适当缩小和增大。

UIButton框架尺寸增加

似乎需要首先确定最大宽度/高度。

在代码中我什至这样设置:

skipButton.titleLabel?.font = UIFont.font(forTextStyle: .body, fontName: .suecaNanoRegular, size: 14)
skipButton.titleLabel?.adjustsFontForContentSizeCategory = true

如何让 UIButton 在运行时支持动态字体大小。

这是我的其他按钮设置(如果有助于调试)。

UIButton设置storyboard动态文本大小字体swift iOS

ios
  • 1 个回答
  • 22 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve