我有以下正则表达式,具有积极的前瞻性:
/black(?=hand)[ s]/
Run Code Online (Sandbox Code Playgroud)
我希望它能与黑人或黑手相匹配.但是,它与任何东西都不匹配.我在Regex101上测试.
我究竟做错了什么?
我需要确定 uicollectionview 的高度。
let layout = contactCollectionView.collectionViewLayout
let heightSize = String(Int(layout.collectionViewContentSize.height))
Run Code Online (Sandbox Code Playgroud)
上述解决方案适用于我项目中的某些情况。在这种特定情况下,我需要计算行数,然后将其与一个数字相乘以找到高度。
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
// height = (count rows) * 30 . every cell height is 30
// every cell has different width.
return (presenter?.selectedContact.count)!
}
Run Code Online (Sandbox Code Playgroud)
如何找到行数?
更新
这是我的收藏视图。每个单元格都有不同的宽度(因为它是字符串)。所以它有不同的行。这个collectionView的宽度是view.frame的宽度
我想在swift 3中创建一个复杂的NSCompoundPredicate,但是,我不知道如何做到这一点.
假设我有5个谓词(p1,p2,p3,p4,p5).我想实现以下条件:
compound1 = (p1 AND p2 AND p3) // NSCompoundPredicate(type: .and,
//subpredicates: predicates)
compound2 = (p4 AND p5) // NSCompoundPredicate(type: .and,
//subpredicates: predicates)
compound3 = (compound1 OR compound2) // problem is here
fetchRequest.predicate = compound3
Run Code Online (Sandbox Code Playgroud)
NSCompoundPredicate因为它的第二个参数获得了它不想要的NSPredicates数组.什么是最好的解决方案?
我在 swift 语言中使用ios-charts。单击 LineChart 中的每个圆圈时,我需要显示更多数据。我只能显示一个值(Y 轴 - 图片中:没有美元符号的价格)。是否可以实现下图?单击时更多值、空圆圈和填充圆圈。