我正在尝试向Realm对象UserDetails添加一个新属性.这是我的尝试:
class CustomerDetails: Object {
dynamic var customer_id = 0
dynamic var customer_name = ""
}
Run Code Online (Sandbox Code Playgroud)
现在我需要将一个新属性"company_name"添加到之前已经创建的UserDetails对象中.如何向现有的Realm对象添加新的?
在这里,我正在尝试突出显示选择的UICollectionViewCell,如图所示.我尝试将边框添加到选定的单元格,边框位于单元格内容视图中.这是我的尝试:
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let cell = priorityCollectionView.cellForItem(at: indexPath) as? BCPriorityListCollectionViewCell
let borderWidth: CGFloat = 6
cell?.contentView.frame = (cell?.labelBackground.frame.insetBy(dx: +borderWidth, dy: +borderWidth))!
cell?.contentView.layer.borderColor = cell?.backgroundColor?.cgColor
cell?.contentView.layer.borderWidth = borderWidth
}
func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) {
let cell = priorityCollectionView.cellForItem(at: indexPath) as? BCPriorityListCollectionViewCell
let borderWidth: CGFloat = 0
cell?.contentView.frame = (cell?.labelBackground.frame.insetBy(dx: +borderWidth, dy: +borderWidth))!
cell?.contentView.layer.borderColor = UIColor.clear.cgColor
cell?.contentView.layer.borderWidth = borderWidth
}
Run Code Online (Sandbox Code Playgroud)
这该怎么做?
我使用Av播放器视图控制器创建了一个启动视频.它适用于所有设备,除了我的手机X.我尝试改变视频重力框架和一切,但它不会工作.关于这个的任何想法?这是示例代码:
guard let videoPath = Bundle.main.path(forResource: "Redtaxi-splash", ofType:"mov") else {
return
}
let videoURL = URL(fileURLWithPath: videoPath)
let player = AVPlayer(url: videoURL)
playerViewController = AVPlayerViewController()
playerViewController?.player = player
playerViewController?.showsPlaybackControls = false
playerViewController?.view.frame = view.frame
playerViewController?.view.backgroundColor = .white
playerViewController?.view.contentMode = .scaleAspectFill
NotificationCenter.default.addObserver(self, selector: #selector(playerDidFinishPlaying(note:)),
name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: player.currentItem)
view.addSubview((playerViewController?.view)!)
playerViewController?.player?.play()
Run Code Online (Sandbox Code Playgroud) 如何像在 SQL 中一样列出领域数据库中的属性SELECT columnName FROM mytable?
这是我的尝试:let person = self.realm.objects(Person.self).filter("age")