小编pab*_*ros的帖子

firebase runTransactionBlock

我正在阅读firebase.google的示例https://firebase.google.com/docs/database/ios/save-data#save_data_as_transactions ,我正在尝试编写自己的版本.我遇到了麻烦,因为firebase示例让我比以前更加困惑

我所要做的就是当一个人点击一个按钮时,它是++(或+ = 1)到计数而另一个按钮将其删除

有人可以帮我弄清楚如何做到这一点...上一个问题的另一个用户发布了其他语言答案的链接,我试图用快速语言写它但我失败了

ios firebase swift firebase-realtime-database

7
推荐指数
1
解决办法
3306
查看次数

如何在其中具有UIStackView的UITableViewCell进行自定义大小

我无法UITableViewCellUIStackView内部进行自我调整。

对于UITableViewCell我正在做这样的事情:

ui

在代码上,我这样做:

override func viewDidLoad() {
    super.viewDidLoad()
    self.tableView.estimatedRowHeight = 80
}
Run Code Online (Sandbox Code Playgroud)

但是当我运行应用程序时,UITableViewCells不会调整大小:

结果

我想在其中进行UITableViewCell自我调整的原因是UIStackView什么?

uitableview ios swift uistackview

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

如何从Kotlin中的Int创建枚举?

我有这个enum

enum class Types(val value: Int) {
    FOO(1)
    BAR(2)
    FOO_BAR(3)
}
Run Code Online (Sandbox Code Playgroud)

如何enum使用创建一个实例Int

我试图做这样的事情:

val type = Types.valueOf(1)
Run Code Online (Sandbox Code Playgroud)

我得到错误:

整数文字不符合预期的字符串类型

kotlin

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

Swift - 在getter上返回自身属性并将其自身设置为setter

无论如何要在getter中返回自己的属性并将其设置在setter上?因为我只想在getter和setter中打印一个日志就可以了.

例如,我试图做这样的事情:

private(set) var internetConnectionAvailable: Bool {
    get {
        logger.debug("verifying internet connection")
        // here return itself property
    }
    set {
        logger.debug("changing internet connection")
        // here set itself
    }
}
Run Code Online (Sandbox Code Playgroud)

如果我回到self.internetConnectionAvailable吸气器上,我得到:

链接器命令失败,退出代码为1

当我尝试编译项目时.

我正在尝试这样做,因为我不想创建额外的私有属性来存储get和set.我正在寻找是否有不同的东西来实现这一目标.

getter-setter swift

5
推荐指数
1
解决办法
1357
查看次数

获取没有 keyboardWillAppear 用户信息通知的键盘框架,iOS

我正在开发一个 iPhone 应用程序,如果发生按钮事件,我必须在其中显示一些自定义选择器。但我不想为我的自定义选择器视图的框架硬编码值。我搜索并找到了keyboardWillShow通知 userInfo 方法,但就我而言,我没有显示键盘,因此无法从中获取框架。任何人都可以帮助我获得可用于我的自定义选择器的键盘框架吗?

keyboard ios swift

5
推荐指数
1
解决办法
2605
查看次数

RealmSwift List要求String继承自Object

我正在尝试这样的字符串列表RealmSwift:

import Foundation
import RealmSwift

// V1
class foo: Object {
    let strings = List<String>()
}
Run Code Online (Sandbox Code Playgroud)

但我得到这个错误:

'List'要求'String'继承自'Object'

无论如何创建一个字符串列表而不创建一个具有一个String属性的整个类Realm

realm swift

5
推荐指数
1
解决办法
2476
查看次数

安装cocoapods时出错:json-1.8.3及更多错误

我无法安装cocoapods.我这样做:

gem install cocoapods
Run Code Online (Sandbox Code Playgroud)

我得到了所有这些错误:

Building native extensions.  This could take a while...
ERROR:  Error installing cocoapods:
    ERROR: Failed to build gem native extension.

    current directory: /usr/local/lib/ruby/gems/2.4.0/gems/json-1.8.3/ext/json/ext/generator
/usr/local/opt/ruby/bin/ruby -r ./siteconf20161228-19158-1ru87yt.rb extconf.rb
creating Makefile

current directory: /usr/local/lib/ruby/gems/2.4.0/gems/json-1.8.3/ext/json/ext/generator
make "DESTDIR=" clean

current directory: /usr/local/lib/ruby/gems/2.4.0/gems/json-1.8.3/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
generator.c:861:25: error: use of undeclared identifier 'rb_cFixnum'
    } else if (klass == rb_cFixnum) {
                        ^
generator.c:863:25: error: use of undeclared identifier 'rb_cBignum'
    } else if (klass == rb_cBignum) {
                        ^
generator.c:975:5: warning: …
Run Code Online (Sandbox Code Playgroud)

rubygems ios cocoapods

5
推荐指数
1
解决办法
584
查看次数

将徽章(补充视图)添加到 UICollectionLayoutListConfiguration

有什么方法可以将徽章NSCollectionLayoutSupplementaryItem) 添加到 a吗UICollectionLayoutListConfiguration

我正在尝试使用现代集合视图实现侧边栏:

var configuration = UICollectionLayoutListConfiguration(appearance: .sidebar)
...

let section = NSCollectionLayoutSection.list(using: configuration, layoutEnvironment: layoutEnvironment)
Run Code Online (Sandbox Code Playgroud)

但我找不到如何实现badge配置:

var configuration = UICollectionLayoutListConfiguration(appearance: .sidebar)
...

let section = NSCollectionLayoutSection.list(using: configuration, layoutEnvironment: layoutEnvironment)
Run Code Online (Sandbox Code Playgroud)

就像Apple提供的示例代码一样:

let badgeAnchor = NSCollectionLayoutAnchor(edges: [.top, .trailing], fractionalOffset: CGPoint(x: 0.3, y: -0.3))
let badgeSize = NSCollectionLayoutSize(widthDimension: .absolute(20),
                                                  heightDimension: .absolute(20))
let badge = NSCollectionLayoutSupplementaryItem(
                layoutSize: badgeSize,
                elementKind: "badge",
                containerAnchor: badgeAnchor)
Run Code Online (Sandbox Code Playgroud)

(苹果提供的示例代码,顺便说一句崩溃了)

关于如何实现徽章UICollectionLayoutListConfiguration或不可能的任何想法?

uikit ios uicollectionview uicollectionviewlayout swift

5
推荐指数
1
解决办法
671
查看次数

StoreKit 2 - 产品请求始终为空

我试图从 using 中获取产品App Store ConnectStoreKit 2但总是返回一个空数组:

let keys = [
    "com.app.suscripcion.mes.1"
]
        
let storeProducts = try await Product.products(for: keys)
Run Code Online (Sandbox Code Playgroud)

我在该部分添加了一个键InApp Purchase

在此输入图像描述

我需要做什么才能从 获取产品App Store Connect?如果我使用.storekit配置文件,它可以工作,但在真实场景中则不起作用

storekit ios swift

5
推荐指数
1
解决办法
2636
查看次数

获取插件com.getdropbox.dropbox.garcon在打开NSOpenPanel时中断

当我打开NSOpenPanel然后我的应用程序崩溃时,我在控制台上收到此消息:

plugin com.getdropbox.dropbox.garcon interrupted
plugin com.getdropbox.dropbox.garcon interrupted
Unable to setup extension context - error: Couldn't communicate with a helper application
Run Code Online (Sandbox Code Playgroud)

在调试器中,我在Thread 6上收到警告说:

Queue: com.apple.NSXPCConnection.user.com.getdropbox.dropbox.garcon.apple-extension-service(serial)
    0_dispatch_barrier_async_f
12 start_wqthread
Enqueued from com.apple.NSXPCConnection.user.com.getdropbox.dropbox.garcon.apple-extension-service (Thread 6)
0_dispatch_barrier_async_f
Run Code Online (Sandbox Code Playgroud)

我尝试用[openPanel runModal]和打开我的NSOpenPannel[openPanel beginSheetModalForWindow:...

我只是用NSOpenPanel来打开一个txt文件

我该怎么做才能停止获取此消息并且应用程序停止崩溃?

该应用程序没有沙盒和代码签名.我只是在Debug-build中尝试,因为我没有Apple开发者帐户.Mac OS X版本为10.10,Dropbox版本为3.0.3

objective-c dropbox nsopenpanel nsxpcconnection

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