小编Alf*_*lfi的帖子

将Xcode更新到版本10.3(10G8)后情节提要断开,并且应用程序不再运行

我刚刚将Xcode更新到版本10.3(10G8)。

现在,我的项目未运行并出现以下错误: 在此处输入图片说明

/* com.apple.actool.errors */
: error: Failed to find a suitable device for the type IBSimDeviceTypeiPad2x (com.apple.dt.Xcode.IBSimDeviceType.iPad-2x) with runtime iOS 12.4 (12.4 - 16G73) - com.apple.CoreSimulator.SimRuntime.iOS-12-4
    Failure Reason: Failed to create new simulator device that matches IBSimDeviceTypeiPad2x (com.apple.dt.Xcode.IBSimDeviceType.iPad-2x) for runtime iOS 12.4 (12.4 - 16G73) - com.apple.CoreSimulator.SimRuntime.iOS-12-4 (Invalid runtime: com.apple.CoreSimulator.SimRuntime.iOS-12-4)
    Underlying Errors:
        Description: Invalid runtime: com.apple.CoreSimulator.SimRuntime.iOS-12-4
/* com.apple.actool.compilation-results */
/Users/xxx/Library/Developer/Xcode/DerivedData/xxxxx-dxlvvymxzdfqjubnuntqlxggtyja/Build/Intermediates.noindex/xxxxx.build/Debug-iphonesimulator/xxxxx.build/assetcatalog_generated_info.plist
Run Code Online (Sandbox Code Playgroud)

现在,情节提要是这样的: 在此处输入图片说明

xcode storyboard

76
推荐指数
2
解决办法
6824
查看次数

iOS 13是否具有获取设备通知令牌的新方法?

所以我的朋友从OneSignal收到了这封电子邮件

由于即将到来的iOS 13版本可能会发生更改,因此在使用Xcode 11构建应用程序之前,必须先更新到最新版本的iOSSDK。OneSignal的所有包装SDK(包括React Native,Unity和Flutter)都已经过也更新了。原因是与iOS 13一起发布的Xcode 11打破了OneSignal之类的应用程序和库用于获取设备推送令牌的通用技术。如果您不使用我们的新SDK,那么新用户将无法从您的应用订阅通知。

我对此感到好奇。

这是我们在iOS 12上获取设备通知令牌的方式

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    var token = ""
    for i in 0..<deviceToken.count {
        token = token + String(format: "%02.2hhx", arguments: [deviceToken[i]])
    }
    print("Notification token = \(token)")
}
Run Code Online (Sandbox Code Playgroud)

在iOS 13上获取它的正确方法是什么?我应该为当前开发的应用程序采用新方法还是旧方法仍然可行?

apple-push-notifications ios13 xcode11

14
推荐指数
2
解决办法
1万
查看次数

无法更改 iOS14 小部件背景颜色

我知道我可以使用以下代码更改 SwiftUI 中的视图背景颜色:

.background(Color(.systemGroupedBackground))
Run Code Online (Sandbox Code Playgroud)

但是我不能为小部件背景颜色本身做到这一点!

我使用这个代码:

struct XWidget: Widget { // MARK: Widget is defined here
    var body: some WidgetConfiguration {
        StaticConfiguration(
            kind: "xWidget",
            provider: xProvider(),
            placeholder: Text("Loading...")) { entry in
            xWidgetEntryView(entry: entry).background(Color(.systemGroupedBackground)) // <= here
        }.supportedFamilies([.systemSmall, .systemMedium, .systemLarge])
    }
}
Run Code Online (Sandbox Code Playgroud)

但结果是这样的:

在此处输入图片说明

widget background-color ios swiftui

12
推荐指数
4
解决办法
6067
查看次数

检查 iOS 14 上的用户位置权限状态

所以我想检查我是否有权访问 iOS14 上的用户位置&我找到了这段代码,但 XCode(12) 对我大喊大叫:

'authorizationStatus()' was deprecated in iOS 14.0
Run Code Online (Sandbox Code Playgroud)

这是代码:

func hasLocationPermission() -> Bool {
       var hasPermission = false
       if CLLocationManager.locationServicesEnabled() {
           switch CLLocationManager.authorizationStatus() { // <= 'authorizationStatus()' was deprecated in iOS 14.0
           case .notDetermined, .restricted, .denied:
               hasPermission = false
           case .authorizedAlways, .authorizedWhenInUse:
               hasPermission = true
           @unknown default:
               hasPermission = false
             }
       } else {
            hasPermission = false
       }
        return hasPermission
}
Run Code Online (Sandbox Code Playgroud)

那么我应该用什么来代替呢?

location swift ios14

8
推荐指数
2
解决办法
1万
查看次数

CLLocationManager 的 AuthorizationStatus 在 iOS 14 上已弃用

我使用此代码来检查我是否有权访问用户位置

if CLLocationManager.locationServicesEnabled() {
    switch CLLocationManager.authorizationStatus() {
        case .restricted, .denied:
            hasPermission = false
        default:
            hasPermission = true
        }
    } else {
        print("Location services are not enabled")
    }
}
Run Code Online (Sandbox Code Playgroud)

Xcode(12) 用这个警告对我大喊大叫:

'authorizationStatus()' was deprecated in iOS 14.0
Run Code Online (Sandbox Code Playgroud)

那么什么是替代品呢?

core-location ios swift ios14

8
推荐指数
1
解决办法
4375
查看次数

如何隐藏或删除Apple Watch状态栏中的时间?

如何从我的应用程序上的Apple Watch状态栏屏幕隐藏或删除小时钟?

我在网上搜索了这个,但一无所获!

我刚刚发现,如果你删除那个时钟,Apple会拒绝你的应用程序,但我的应用程序本身就是一个表盘而且不需要显示那个时间.

user-interface apple-watch watchkit watchos

7
推荐指数
2
解决办法
3278
查看次数

无法在 mac 屏幕保护程序发布版本上加载图像(它适用于 Xcode 调试版本)

我从这里得到了这个 mac 屏幕保护程序示例。

我将其更改为显示图像而不是 textField。

问题是:它可以显示任何 Xcode 对象,例如 textView。textField、Button 等...但它无法在 imageView 上加载图像。(它可以在 Xcode 调试版本上加载图像,但不能在 mac 屏幕保护程序上的发布版本上加载图像)

调试构建屏幕截图

发布构建截图 . 这是我显示图像的代码:

  let imageView = NSImageView(frame: self.frame)
  imageView.image = NSImage(named: "Image")
  imageView.layer?.backgroundColor = NSColor.red.cgColor
  imageView.backgroundColor(.red)
  addSubview(imageView)
  DispatchQueue.main.async {
      imageView.frame = CGRect(x: 100, y: 100, width: 200, height: 100)
      self.setNeedsDisplay(imageView.frame)
  }
Run Code Online (Sandbox Code Playgroud)

我很确定它无法访问图像文件,但我该如何解决这个问题?实际上,屏幕保护程序的行为非常奇怪,当我在 ImageView 之后添加另一个 UI 元素时,它们都没有显示在屏幕上。

macOS 屏幕保护程序有什么问题?(我从一些网站下载了一些第三方屏幕保护程序,它们也是黑屏。)

macos xcode screensaver swift

6
推荐指数
1
解决办法
244
查看次数

如何为iOS13上下文菜单操作设置自定义字体?

我想为 iOS 13+ 自定义上下文菜单上的操作按钮

菜单是这样的:

在此输入图像描述

我想我可以像 UIAlertController 操作一样设置自定义字体,如下所示:

let action = UIAction(title: "asdasd") { _ in}
let attributeString = NSMutableAttributedString(string: action.title)
attributeString.addAttributes([NSAttributedString.Key.font : font], range: NSMakeRange(0, action.title.count))
action.setValue(attributeString, forKey: "attributedMessage")
Run Code Online (Sandbox Code Playgroud)

但它不是这样工作的,那是怎么回事呢?

fonts contextmenu custom-font swift ios13

6
推荐指数
1
解决办法
2383
查看次数

如何知道在(iOS 13+)configurationForMenuAtLocation 上为上下文菜单触发了哪个 UICollectionView 单元格

在 iOS 13 上,我们为 tableView 和 collectionView 提供了漂亮的上下文菜单。

我在 UICollectionView 上使用它,如下所示:

'cellForItemAt indexPath' 上的实现:

let interaction = UIContextMenuInteraction(delegate: self)
cell.moreButton.isUserInteractionEnabled = false
cell.moreButton.tag = indexPath.row
cell.addInteraction(interaction)
Run Code Online (Sandbox Code Playgroud)

在“configurationForMenuAtLocation 位置”上处理老虎

func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? {
        let configuration = UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { suggestedActions in
            var actions = [UIAction]()
            for item in self.contextMenuItems {
                let action = UIAction(title: item.title, image: item.image, identifier: nil, discoverabilityTitle: nil) { _ in
                self.didSelectContextMenu(index: 0) <== how pass the index from here? …
Run Code Online (Sandbox Code Playgroud)

contextmenu uicollectionview swift ios13

4
推荐指数
1
解决办法
1595
查看次数

使用简单的 https 请求更新 Firestore 数据库(云)上的单个字段

我目前正在使用 Swift (macOS),这没关系。

我可以使用来自 Firestore 的这个简单的 get 请求来获取我的数据库数据

https://firestore.googleapis.com/v1beta1/projects/MY_PROJECT_NAME/databases/(default)/documents/" + "User_email" + "?pageSize=100&pageToken=" + "NextPage_Id"
Run Code Online (Sandbox Code Playgroud)

现在我想更新数据库上的一个文件,我不知道如何。

Firebase api 指南对我来说太复杂了,我不明白。

我发现这个获取请求网址:

https://firestore.googleapis.com/v1beta1/projects/{projectId}/databases/{databaseId}/documents/{document_path}?updateMask.fieldPaths=status&updateMask.fieldPaths=title
Run Code Online (Sandbox Code Playgroud)

但是当我尝试时,它给了我这个错误:

 {
"details" : [
  {
    "fieldViolations" : [
      {
        "description" : "Invalid JSON payload received. Unknown name \"updateMask.fieldPaths\": Cannot bind query parameter. Field 'updateMask' could not be found in request message."
      }
    ],
    "@type" : "type.googleapis.com\/google.rpc.BadRequest"
  }
],
"code" : 400,
"message" : "Invalid JSON payload received. Unknown name \"updateMask.fieldPaths\": Cannot bind query parameter. Field 'updateMask' could not …
Run Code Online (Sandbox Code Playgroud)

api web google-cloud-firestore

3
推荐指数
1
解决办法
676
查看次数