我如何使用 iosMath在 iOS 上的 Swift 中,因为 iosMath 是用 Objective C 编写的?还是有其他方法可以使用 Swift 显示数学公式?
最佳答案
我会尽快完成:
1.) 安装 cocoaPods(打开终端并输入 sudo gem install cocoapods
)
2.) 从终端更改目录到您的项目并初始化 cocoaPods 并像这样编辑 Podfile:
cd /ProjectFolder
pod init
nano podFile
(打开 podfile,在其中粘贴 pod 存储库),应该如下所示:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'mathExample' do
# Comment the next line if you're not using Swift and don't want to use dynam$
use_frameworks!
# Pods for mathExample
pod 'iosMath'
end
保存 podfile 并通过以下方式安装:
pod install
从现在开始,使用工作区文件而不是项目文件...我们现在已完成安装您需要的 pod...
现在有点棘手 -> 你需要将新的 Objective-C 文件添加到项目中(所以只需新建文件 -> Objective-C 文件并选择创建桥接 header )从现在开始,你可以删除创建的文件(但不是桥接头文件)
从现在开始,您可以像使用 swift 框架一样使用 Objective-C 框架,不要忘记将该框架导入到您将使用它的类中:
import UIKit
//Importing our module
import iosMath
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
print(iosMathVersionNumber)
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
希望这对您有所帮助,祝您编码愉快! :)
关于ios - 在 Swift 中使用 iosMath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44228429/