我今天刚下载了 Ruby、Git、Rails 和 Homebrew。我通过 rvm v. 1.29.0 安装了 ruby 我的 Ruby 是 2.4.0 版,Rails 是 5.0.1。我的 macOS 是 10.12 Sierra。
当我尝试通过这样做来制作测试应用程序时,
rails new test_app
给了我一个错误:
`Could not load OpenSSL.
You must recompile Ruby with OpenSSL support or change the sources in your
Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL using
RVM are available at rvm.io/packages/openssl.`
run bundle exec spring binstub --all
bundler: command not found: spring
Install missing gem executables with `bundle install`
Run Code Online (Sandbox Code Playgroud)
所以我尝试了一个 bundle install 命令,其中同样的错误 …
我目前在 UITextField 上有以下扩展来计算给定字符串的边界矩形。
func widthHeight(font: UIFont) -> CGRect {
let constraintRect = CGSize(width: 200, height: 1000)
let boundingBox = self.boundingRect(with: constraintRect, options: .usesLineFragmentOrigin, attributes: [NSFontAttributeName: font], context: nil)
return boundingBox
}
Run Code Online (Sandbox Code Playgroud)
的宽度constraintRect是我想要允许的盒子的最大宽度。
我像这样设置值和单元格:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuse, for: indexPath) as? ChatCollectionViewCell {
let text = self.chatLog[indexPath.row].text
cell.chatTextView.text = text
cell.chatViewWidth = (text?.widthHeight(font: UIFont.systemFont(ofSize: 16)).width)!
return cell
}
return UICollectionViewCell()
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: …Run Code Online (Sandbox Code Playgroud)